>>=26,t.words[n]=i,e=r}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new M;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new N}return v[t]=e,e},I.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},I.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},I.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},I.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},I.prototype.add=function(t,e){this._verify2(t,e);var n=t.add(e);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},I.prototype.iadd=function(t,e){this._verify2(t,e);var n=t.iadd(e);return n.cmp(this.m)>=0&&n.isub(this.m),n},I.prototype.sub=function(t,e){this._verify2(t,e);var n=t.sub(e);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},I.prototype.isub=function(t,e){this._verify2(t,e);var n=t.isub(e);return n.cmpn(0)<0&&n.iadd(this.m),n},I.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},I.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},I.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},I.prototype.isqr=function(t){return this.imul(t,t.clone())},I.prototype.sqr=function(t){return this.mul(t,t)},I.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new i(1)).iushrn(2);return this.pow(t,r)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);n(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var h=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),p=a;0!==f.cmp(s);){for(var y=f,m=0;0!==y.cmp(s);m++)y=y.redSqr();n(m=0;r--){for(var c=e.words[r],l=u-1;l>=0;l--){var h=c>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===r&&0===l)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}u=26}return o},I.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},I.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new E(t)},r(E,I),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var n=t.imul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var n=t.mul(e),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).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)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,Gf)}));
+var Es=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ks=BigInt(1),Ts=BigInt(2),Ls=function(t,e){return(t+e/Ts)/e};var Ss,js,Cs,Ds=On(Es,void 0,void 0,{sqrt:function(t){var e=Es,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=t*t*t%e,l=c*c*t%e,h=kn(l,n,e)*l%e,d=kn(h,n,e)*l%e,f=kn(d,Ts,e)*c%e,p=kn(f,i,e)*f%e,y=kn(p,o,e)*p%e,m=kn(y,s,e)*y%e,g=kn(m,u,e)*m%e,v=kn(g,s,e)*y%e,w=kn(v,n,e)*l%e,b=kn(w,a,e)*p%e,M=kn(b,r,e)*c%e,A=kn(M,Ts,e);if(!Ds.eql(Ds.sqr(A),t))throw new Error("Cannot find square root");return A}}),Os=(Ss={a:BigInt(0),b:BigInt(7),Fp:Ds,n:xs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:function(t){var e=xs,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ks*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,a=BigInt("0x100000000000000000000000000000000"),s=Ls(o*t,e),u=Ls(-r*t,e),c=En(t-s*n-u*i,e),l=En(-s*r-u*o,e),h=c>a,d=l>a;if(h&&(c=e-c),d&&(l=e-l),c>a||l>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:l}}}},js=vr,Cs=function(t){return As(D(D({},Ss),function(t){return{hash:t,hmac:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i32)throw new Error("Invalid public key input")}return e}return U(a,[{key:"equals",value:function(t){return this._bn.eq(t._bn)}},{key:"toBase58",value:function(){return dr.encode(this.toBytes())}},{key:"toJSON",value:function(){return this.toBase58()}},{key:"toBytes",value:function(){var t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}},{key:"toBuffer",value:function(){var t=this._bn.toArrayLike(It);if(32===t.length)return t;var e=It.alloc(32);return t.copy(e,32-t.length),e}},{key:e,get:function(){return"PublicKey(".concat(this.toString(),")")}},{key:"toString",value:function(){return this.toBase58()}}],[{key:"unique",value:function(){var t=new a(Js);return Js+=1,new a(t.toBuffer())}},{key:"createWithSeed",value:(i=_(O().mark((function t(e,n,r){var i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=It.concat([e.toBuffer(),It.from(n),r.toBuffer()]),o=vr(i),t.abrupt("return",new a(o));case 3:case"end":return t.stop()}}),t)}))),function(t,e,n){return i.apply(this,arguments)})},{key:"createProgramAddressSync",value:function(t,e){var n=It.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");n=It.concat([n,Hs(t)])})),n=It.concat([n,e.toBuffer(),It.from("ProgramDerivedAddress")]);var r=vr(n);if(Ys(r))throw new Error("Invalid seeds, address must fall off the curve");return new a(r)}},{key:"createProgramAddress",value:(r=_(O().mark((function t(e,n){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.createProgramAddressSync(e,n));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"findProgramAddressSync",value:function(t,e){for(var n,r=255;0!=r;){try{var i=t.concat(It.from([r]));n=this.createProgramAddressSync(i,e)}catch(t){if(t instanceof TypeError)throw t;r--;continue}return[n,r]}throw new Error("Unable to find a viable program address nonce")}},{key:"findProgramAddress",value:(n=_(O().mark((function t(e,n){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.findProgramAddressSync(e,n));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return n.apply(this,arguments)})},{key:"isOnCurve",value:function(t){return Ys(new a(t).toBytes())}}]),a}(0,Symbol.toStringTag);Ws=Xs,Xs.default=new Ws("11111111111111111111111111111111"),Zs.set(Xs,{kind:"struct",fields:[["_bn","u256"]]});var Ks=function(){function t(e){if(B(this,t),this._publicKey=void 0,this._secretKey=void 0,e){var n=Hs(e);if(64!==e.length)throw new Error("bad secret key size");this._publicKey=n.slice(32,64),this._secretKey=n.slice(0,32)}else this._secretKey=Hs(Rs()),this._publicKey=Hs(Qs(this._secretKey))}return U(t,[{key:"publicKey",get:function(){return new Xs(this._publicKey)}},{key:"secretKey",get:function(){return It.concat([this._secretKey,this._publicKey],64)}}]),t}(),$s=new Xs("BPFLoader1111111111111111111111111111111111"),tu=function(t){Y(n,G(Error));var e=X(n);function n(t){var r;return B(this,n),(r=e.call(this,"Signature ".concat(t," has expired: block height exceeded."))).signature=void 0,r.signature=t,r}return U(n)}();Object.defineProperty(tu.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});var eu=function(t){Y(n,G(Error));var e=X(n);function n(t,r){var i;return B(this,n),(i=e.call(this,"Transaction was not confirmed in ".concat(r.toFixed(2)," seconds. It is ")+"unknown if it succeeded or failed. Check signature "+"".concat(t," using the Solana Explorer or CLI tools."))).signature=void 0,i.signature=t,i}return U(n)}();Object.defineProperty(eu.prototype,"name",{value:"TransactionExpiredTimeoutError"});var nu=function(t){Y(n,G(Error));var e=X(n);function n(t){var r;return B(this,n),(r=e.call(this,"Signature ".concat(t," has expired: the nonce is no longer valid."))).signature=void 0,r.signature=t,r}return U(n)}();Object.defineProperty(nu.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});var ru=function(){function t(e,n){B(this,t),this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}return U(t,[{key:"keySegments",value:function(){var t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}},{key:"get",value:function(t){var e,n=st(this.keySegments());try{for(n.s();!(e=n.n()).done;){var r=e.value;if(t256)throw new Error("Account index overflow encountered during compilation");var e=new Map;this.keySegments().flat().forEach((function(t,n){e.set(t.toBase58(),n)}));var n=function(t){var n=e.get(t.toBase58());if(void 0===n)throw new Error("Encountered an unknown instruction account key during compilation");return n};return t.map((function(t){return{programIdIndex:n(t.programId),accountKeyIndexes:t.keys.map((function(t){return n(t.pubkey)})),data:t.data}}))}}]),t}(),iu=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"publicKey";return Hi(32,t)},ou=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature";return Hi(64,t)},au=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"string",e=Fi([Qi("length"),Qi("lengthPadding"),Hi(Bi(Qi(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),i=e;return i.decode=function(t,e){return n(t,e).chars.toString()},i.encode=function(t,e,n){var i={chars:It.from(t,"utf8")};return r(i,e,n)},i.alloc=function(t){return Qi().span+Qi().span+It.from(t,"utf8").length},i};function su(t,e){var n=function t(n){if(n.span>=0)return n.span;if("function"==typeof n.alloc)return n.alloc(e[n.property]);if("count"in n&&"elementLayout"in n){var r=e[n.property];if(Array.isArray(r))return r.length*t(n.elementLayout)}else if("fields"in n)return su({layout:n},e[n.property]);return 0},r=0;return t.layout.fields.forEach((function(t){r+=n(t)})),r}function uu(t){for(var e=0,n=0;;){var r=t.shift();if(e|=(127&r)<<7*n,n+=1,0==(128&r))break}return e}function cu(t,e){for(var n=e;;){var r=127&n;if(0==(n>>=7)){t.push(r);break}r|=128,t.push(r)}}function lu(t,e){if(!t)throw new Error(e||"Assertion failed")}var hu=function(){function t(e,n){B(this,t),this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}return U(t,[{key:"getMessageComponents",value:function(){var t=et(this.keyMetaMap.entries());lu(t.length<=256,"Max static account keys length exceeded");var e=t.filter((function(t){var e=tt(t,2)[1];return e.isSigner&&e.isWritable})),n=t.filter((function(t){var e=tt(t,2)[1];return e.isSigner&&!e.isWritable})),r=t.filter((function(t){var e=tt(t,2)[1];return!e.isSigner&&e.isWritable})),i=t.filter((function(t){var e=tt(t,2)[1];return!e.isSigner&&!e.isWritable})),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};return lu(e.length>0,"Expected at least one writable signer key"),lu(tt(e[0],1)[0]===this.payer.toBase58(),"Expected first writable signer key to be the fee payer"),[o,[].concat(et(e.map((function(t){var e=tt(t,1)[0];return new Xs(e)}))),et(n.map((function(t){var e=tt(t,1)[0];return new Xs(e)}))),et(r.map((function(t){var e=tt(t,1)[0];return new Xs(e)}))),et(i.map((function(t){var e=tt(t,1)[0];return new Xs(e)}))))]}},{key:"extractTableLookup",value:function(t){var e=tt(this.drainKeysFoundInLookupTable(t.state.addresses,(function(t){return!t.isSigner&&!t.isInvoked&&t.isWritable})),2),n=e[0],r=e[1],i=tt(this.drainKeysFoundInLookupTable(t.state.addresses,(function(t){return!t.isSigner&&!t.isInvoked&&!t.isWritable})),2),o=i[0],a=i[1];if(0!==n.length||0!==o.length)return[{accountKey:t.key,writableIndexes:n,readonlyIndexes:o},{writable:r,readonly:a}]}},{key:"drainKeysFoundInLookupTable",value:function(t,e){var n,r=this,i=new Array,o=new Array,a=st(this.keyMetaMap.entries());try{var s=function(){var a=tt(n.value,2),s=a[0],u=a[1];if(e(u)){var c=new Xs(s),l=t.findIndex((function(t){return t.equals(c)}));l>=0&&(lu(l<256,"Max lookup table index exceeded"),i.push(l),o.push(c),r.keyMetaMap.delete(s))}};for(a.s();!(n=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}return[i,o]}}],[{key:"compile",value:function(e,n){var r=new Map,i=function(t){var e=t.toBase58(),n=r.get(e);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(e,n)),n},o=i(n);o.isSigner=!0,o.isWritable=!0;var a,s=st(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;i(u.programId).isInvoked=!0;var c,l=st(u.keys);try{for(l.s();!(c=l.n()).done;){var h=c.value,d=i(h.pubkey);d.isSigner||(d.isSigner=h.isSigner),d.isWritable||(d.isWritable=h.isWritable)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){s.e(t)}finally{s.f()}return new t(n,r)}}]),t}(),du=function(){function t(e){var n=this;B(this,t),this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map((function(t){return new Xs(t)})),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach((function(t){return n.indexToProgramIds.set(t.programIdIndex,n.accountKeys[t.programIdIndex])}))}return U(t,[{key:"version",get:function(){return"legacy"}},{key:"staticAccountKeys",get:function(){return this.accountKeys}},{key:"compiledInstructions",get:function(){return this.instructions.map((function(t){return{programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:dr.decode(t.data)}}))}},{key:"addressTableLookups",get:function(){return[]}},{key:"getAccountKeys",value:function(){return new ru(this.staticAccountKeys)}},{key:"isAccountSigner",value:function(t){return t=this.header.numRequiredSignatures?t-e0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new ru(this.staticAccountKeys,e)}},{key:"isAccountSigner",value:function(t){return t=n?t-n=this.header.numRequiredSignatures?t-e0?this.signatures[0].signature:null}},{key:"toJSON",value:function(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map((function(t){return t.toJSON()})),signers:this.signatures.map((function(t){return t.publicKey.toJSON()}))}}},{key:"add",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r0&&this.signatures[0].publicKey))throw new Error("Transaction fee payer required");n=this.signatures[0].publicKey}for(var r=0;r-1?(a[n].isWritable=a[n].isWritable||t.isWritable,a[n].isSigner=a[n].isSigner||t.isSigner):a.push(t)})),a.sort((function(t,e){if(t.isSigner!==e.isSigner)return t.isSigner?-1:1;if(t.isWritable!==e.isWritable)return t.isWritable?-1:1;return t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));var s=a.findIndex((function(t){return t.pubkey.equals(n)}));if(s>-1){var u=tt(a.splice(s,1),1)[0];u.isSigner=!0,u.isWritable=!0,a.unshift(u)}else a.unshift({pubkey:n,isSigner:!0,isWritable:!0});var c,l=st(this.signatures);try{var h=function(){var t=c.value,e=a.findIndex((function(e){return e.pubkey.equals(t.publicKey)}));if(!(e>-1))throw new Error("unknown signer: ".concat(t.publicKey.toString()));a[e].isSigner||(a[e].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."))};for(l.s();!(c=l.n()).done;)h()}catch(t){l.e(t)}finally{l.f()}var d=0,f=0,p=0,y=[],m=[];a.forEach((function(t){var e=t.pubkey,n=t.isSigner,r=t.isWritable;n?(y.push(e.toString()),d+=1,r||(f+=1)):(m.push(e.toString()),r||(p+=1))}));var g=y.concat(m),v=e.map((function(t){var e=t.data,n=t.programId;return{programIdIndex:g.indexOf(n.toString()),accounts:t.keys.map((function(t){return g.indexOf(t.pubkey.toString())})),data:dr.encode(e)}}));return v.forEach((function(t){lu(t.programIdIndex>=0),t.accounts.forEach((function(t){return lu(t>=0)}))})),new du({header:{numRequiredSignatures:d,numReadonlySignedAccounts:f,numReadonlyUnsignedAccounts:p},accountKeys:g,recentBlockhash:t,instructions:v})}},{key:"_compile",value:function(){var t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);if(this.signatures.length===e.length&&this.signatures.every((function(t,n){return e[n].equals(t.publicKey)})))return t;return this.signatures=e.map((function(t){return{signature:null,publicKey:t}})),t}},{key:"serializeMessage",value:function(){return this._compile().serialize()}},{key:"getEstimatedFee",value:(e=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFeeForMessage(this.compileMessage());case 2:return t.abrupt("return",t.sent.value);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"setSigners",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n1?r-1:0),o=1;o ").concat(1232)),i}},{key:"keys",get:function(){return lu(1===this.instructions.length),this.instructions[0].keys.map((function(t){return t.pubkey}))}},{key:"programId",get:function(){return lu(1===this.instructions.length),this.instructions[0].programId}},{key:"data",get:function(){return lu(1===this.instructions.length),this.instructions[0].data}}],[{key:"from",value:function(e){for(var n=et(e),r=uu(n),i=[],o=0;o1&&void 0!==arguments[1]?arguments[1]:[],r=new t;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((function(t,n){var i={signature:t==dr.encode(mu)?null:dr.decode(t),publicKey:e.accountKeys[n]};r.signatures.push(i)})),e.instructions.forEach((function(t){var n=t.accounts.map((function(t){var n=e.accountKeys[t];return{pubkey:n,isSigner:r.signatures.some((function(t){return t.publicKey.toString()===n.toString()}))||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}}));r.instructions.push(new gu({keys:n,programId:e.accountKeys[t.programIdIndex],data:dr.decode(t.data)}))})),r._message=e,r._json=r.toJSON(),r}}]),t}(),wu=function(){function t(e){B(this,t),this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}return U(t,[{key:"compileToLegacyMessage",value:function(){return du.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}},{key:"compileToV0Message",value:function(t){return fu.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}],[{key:"decompile",value:function(e,n){var r=e.header,i=e.compiledInstructions,o=e.recentBlockhash,a=r.numRequiredSignatures,s=r.numReadonlySignedAccounts,u=r.numReadonlyUnsignedAccounts,c=a-s;lu(c>0,"Message header is invalid");var l=e.staticAccountKeys.length-a-u;lu(l>=0,"Message header is invalid");var h=e.getAccountKeys(n),d=h.get(0);if(void 0===d)throw new Error("Failed to decompile message because no account keys were found");var f,p=[],y=st(i);try{for(y.s();!(f=y.n()).done;){var m,g=f.value,v=[],w=st(g.accountKeyIndexes);try{for(w.s();!(m=w.n()).done;){var b=m.value,M=h.get(b);if(void 0===M)throw new Error("Failed to find key for account key index ".concat(b));var A=void 0;A=b=0,"Cannot sign with non signer key ".concat(t.publicKey.toBase58())),n.signatures[o]=Fs(r,t.secretKey)};for(o.s();!(e=o.n()).done;)a()}catch(t){o.e(t)}finally{o.f()}}},{key:"addSignature",value:function(t,e){lu(64===e.byteLength,"Signature must be 64 bytes long");var n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((function(e){return e.equals(t)}));lu(n>=0,"Can not add signature; `".concat(t.toBase58(),"` is not required to sign this transaction")),this.signatures[n]=e}}],[{key:"deserialize",value:function(e){for(var n=et(e),r=[],i=uu(n),o=0;o=0?t.layout.span:su(t,e),r=It.alloc(n),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,r),r}function Ou(t,e){var n;try{n=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(n.instruction!==t.index)throw new Error("invalid instruction; instruction index mismatch ".concat(n.instruction," != ").concat(t.index));return n}var zu,Pu=Yi("lamportsPerSignature"),_u=Fi([Qi("version"),Qi("state"),iu("authorizedPubkey"),iu("nonce"),Fi([Pu],"feeCalculator")]),Bu=_u.span,Ru=function(){function t(e){B(this,t),this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}return U(t,null,[{key:"fromAccountData",value:function(e){var n=_u.decode(Hs(e),0);return new t({authorizedPubkey:new Xs(n.authorizedPubkey),nonce:new Xs(n.nonce).toString(),feeCalculator:n.feeCalculator})}}]),t}(),Uu=(zu=8,function(t){var e=Hi(zu,t),n=function(t){return{decode:t.decode.bind(t),encode:t.encode.bind(t)}}(e),r=n.encode,i=n.decode,o=e;return o.decode=function(t,e){var n=i(t,e);return qi(It.from(n))},o.encode=function(t,e,n){var i=Zi(t,zu);return r(i,e,n)},o}),Qu=function(){function t(){B(this,t)}return U(t,null,[{key:"decodeInstructionType",value:function(t){this.checkProgramId(t.programId);for(var e,n=Qi("instruction").decode(t.data),r=0,i=Object.entries(Yu);r0?s:1,space:a.length,programId:o}));case 17:if(null===c){e.next=20;break}return e.next=20,Su(n,c,[r,i],{commitment:"confirmed"});case 20:l=Fi([Qi("instruction"),Qi("offset"),Qi("bytesLength"),Qi("bytesLengthPadding"),Vi(Ri("byte"),Bi(Qi(),-8),"bytes")]),h=t.chunkSize,d=0,f=a,p=[];case 25:if(!(f.length>0)){e.next=39;break}if(y=f.slice(0,h),m=It.alloc(h+16),l.encode({instruction:0,offset:d,bytes:y,bytesLength:0,bytesLengthPadding:0},m),g=(new vu).add({keys:[{pubkey:i.publicKey,isSigner:!0,isWritable:!0}],programId:o,data:m}),p.push(Su(n,g,[r,i],{commitment:"confirmed"})),!n._rpcEndpoint.includes("solana.com")){e.next=35;break}return e.next=35,Cu(250);case 35:d+=h,f=f.slice(h),e.next=25;break;case 39:return e.next=41,Promise.all(p);case 41:return v=Fi([Qi("instruction")]),w=It.alloc(v.span),v.encode({instruction:1},w),b=(new vu).add({keys:[{pubkey:i.publicKey,isSigner:!0,isWritable:!0},{pubkey:Eu,isSigner:!1,isWritable:!1}],programId:o,data:w}),M="processed",e.next=48,n.sendTransaction(b,[r,i],{preflightCommitment:M});case 48:return A=e.sent,e.next=51,n.confirmTransaction({signature:A,lastValidBlockHeight:b.lastValidBlockHeight,blockhash:b.recentBlockhash},M);case 51:if(N=e.sent,I=N.context,!(E=N.value).err){e.next=56;break}throw new Error("Transaction ".concat(A," failed (").concat(JSON.stringify(E),")"));case 56:return e.prev=57,e.next=60,n.getSlot({commitment:M});case 60:if(!(e.sent>I.slot)){e.next=63;break}return e.abrupt("break",71);case 63:e.next=67;break;case 65:e.prev=65,e.t0=e.catch(57);case 67:return e.next=69,new Promise((function(t){return setTimeout(t,Math.round(200))}));case 69:e.next=56;break;case 71:return e.abrupt("return",!0);case 72:case"end":return e.stop()}}),e,null,[[57,65]])}))),function(t,n,r,i,o){return e.apply(this,arguments)})}]),t}();Fu.chunkSize=932;var Vu=new Xs("BPFLoader2111111111111111111111111111111111"),Hu=function(){function t(){B(this,t)}return U(t,null,[{key:"getMinNumSignatures",value:function(t){return Fu.getMinNumSignatures(t)}},{key:"load",value:function(t,e,n,r,i){return Fu.load(t,e,n,i,r)}}]),t}();function Gu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qu=Object.prototype.toString,Zu=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function Ju(t,e){var n,r,i,o,a,s,u;if(!0===t)return"true";if(!1===t)return"false";switch(z(t)){case"object":if(null===t)return null;if(t.toJSON&&"function"==typeof t.toJSON)return Ju(t.toJSON(),e);if("[object Array]"===(u=qu.call(t))){for(i="[",r=t.length-1,n=0;n-1&&(i+=Ju(t[n],!0)),i+"]"}if("[object Object]"===u){for(r=(o=Zu(t).sort()).length,i="",n=0;n1;)t/=2,e++;return e}var $u=function(){function t(e,n,r,i,o){B(this,t),this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=n,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=o}return U(t,[{key:"getEpoch",value:function(t){return this.getEpochAndSlotIndex(t)[0]}},{key:"getEpochAndSlotIndex",value:function(t){if(t>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,1+(t|=t>>32))}(t+32+1))-Ku(32)-1;return[e,t-(this.getSlotsInEpoch(e)-32)]}var n=t-this.firstNormalSlot,r=Math.floor(n/this.slotsPerEpoch);return[this.firstNormalEpoch+r,n%this.slotsPerEpoch]}},{key:"getFirstSlotInEpoch",value:function(t){return t<=this.firstNormalEpoch?32*(Math.pow(2,t)-1):(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}},{key:"getLastSlotInEpoch",value:function(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}},{key:"getSlotsInEpoch",value:function(t){return t=0,"lookup table is invalid"),lu(n%32==0,"lookup table is invalid");var r=n/32,i=Fi([Vi(iu(),r,"addresses")]).decode(t.slice(56)).addresses;return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:0!==e.authority.length?new Xs(e.authority[0]):void 0,addresses:i.map((function(t){return new Xs(t)}))}}}]),t}(),oc={index:1,layout:Fi([Qi("typeIndex"),Uu("deactivationSlot"),Yi("lastExtendedSlot"),Ri("lastExtendedStartIndex"),Ri(),Vi(iu(),Bi(Ri(),-1),"authority")])},ac=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;var sc=ko(mo(Xs),Ao(),(function(t){return new Xs(t)})),uc=No([Ao(),go("base64")]),cc=ko(mo(It),uc,(function(t){return It.from(t[0],"base64")}));function lc(t){var e,n;if("string"==typeof t)e=t;else if(t){e=t.commitment,n=q(t,zs)}return{commitment:e,config:n}}function hc(t){return Eo([Io({jsonrpc:go("2.0"),id:Ao(),result:t}),Io({jsonrpc:go("2.0"),id:Ao(),error:Io({code:xo(),message:Ao(),data:bo(fo("any",(function(){return!0})))})})])}var dc=hc(xo());function fc(t){return ko(hc(t),dc,(function(e){return"error"in e?e:D(D({},e),{},{result:co(e.result,t)})}))}function pc(t){return fc(Io({context:Io({slot:wo()}),value:t}))}function yc(t){return Io({context:Io({slot:wo()}),value:t})}function mc(t,e){return 0===t?new fu({header:e.header,staticAccountKeys:e.accountKeys.map((function(t){return new Xs(t)})),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map((function(t){return{programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:dr.decode(t.data)}})),addressTableLookups:e.addressTableLookups}):new du(e)}var gc=Io({foundation:wo(),foundationTerm:wo(),initial:wo(),taper:wo(),terminal:wo()}),vc=fc(po(vo(Io({epoch:wo(),effectiveSlot:wo(),amount:wo(),postBalance:wo(),commission:bo(vo(wo()))})))),wc=po(Io({slot:wo(),prioritizationFee:wo()})),bc=Io({total:wo(),validator:wo(),foundation:wo(),epoch:wo()}),Mc=Io({epoch:wo(),slotIndex:wo(),slotsInEpoch:wo(),absoluteSlot:wo(),blockHeight:bo(wo()),transactionCount:bo(wo())}),Ac=Io({slotsPerEpoch:wo(),leaderScheduleSlotOffset:wo(),warmup:yo(),firstNormalEpoch:wo(),firstNormalSlot:wo()}),Nc=Mo(Ao(),po(wo())),Ic=vo(Eo([Io({}),Ao()])),Ec=Io({err:Ic}),xc=go("receivedSignature"),kc=Io({"solana-core":Ao(),"feature-set":bo(wo())}),Tc=pc(Io({err:vo(Eo([Io({}),Ao()])),logs:vo(po(Ao())),accounts:bo(vo(po(vo(Io({executable:yo(),owner:Ao(),lamports:wo(),data:po(Ao()),rentEpoch:bo(wo())}))))),unitsConsumed:bo(wo()),returnData:bo(vo(Io({programId:Ao(),data:No([Ao(),go("base64")])})))})),Lc=pc(Io({byIdentity:Mo(Ao(),po(wo())),range:Io({firstSlot:wo(),lastSlot:wo()})}));var Sc=fc(gc),jc=fc(bc),Cc=fc(wc),Dc=fc(Mc),Oc=fc(Ac),zc=fc(Nc),Pc=fc(wo()),_c=pc(Io({total:wo(),circulating:wo(),nonCirculating:wo(),nonCirculatingAccounts:po(sc)})),Bc=Io({amount:Ao(),uiAmount:vo(wo()),decimals:wo(),uiAmountString:bo(Ao())}),Rc=pc(po(Io({address:sc,amount:Ao(),uiAmount:vo(wo()),decimals:wo(),uiAmountString:bo(Ao())}))),Uc=pc(po(Io({pubkey:sc,account:Io({executable:yo(),owner:sc,lamports:wo(),data:cc,rentEpoch:wo()})}))),Qc=Io({program:Ao(),parsed:xo(),space:wo()}),Yc=pc(po(Io({pubkey:sc,account:Io({executable:yo(),owner:sc,lamports:wo(),data:Qc,rentEpoch:wo()})}))),Wc=pc(po(Io({lamports:wo(),address:sc}))),Fc=Io({executable:yo(),owner:sc,lamports:wo(),data:cc,rentEpoch:wo()}),Vc=Io({pubkey:sc,account:Fc}),Hc=ko(Eo([mo(It),Qc]),Eo([uc,Qc]),(function(t){return Array.isArray(t)?co(t,cc):t})),Gc=Io({executable:yo(),owner:sc,lamports:wo(),data:Hc,rentEpoch:wo()}),qc=Io({pubkey:sc,account:Gc}),Zc=Io({state:Eo([go("active"),go("inactive"),go("activating"),go("deactivating")]),active:wo(),inactive:wo()}),Jc=fc(po(Io({signature:Ao(),slot:wo(),err:Ic,memo:vo(Ao()),blockTime:bo(vo(wo()))}))),Xc=fc(po(Io({signature:Ao(),slot:wo(),err:Ic,memo:vo(Ao()),blockTime:bo(vo(wo()))}))),Kc=Io({subscription:wo(),result:yc(Fc)}),$c=Io({pubkey:sc,account:Fc}),tl=Io({subscription:wo(),result:yc($c)}),el=Io({parent:wo(),slot:wo(),root:wo()}),nl=Io({subscription:wo(),result:el}),rl=Eo([Io({type:Eo([go("firstShredReceived"),go("completed"),go("optimisticConfirmation"),go("root")]),slot:wo(),timestamp:wo()}),Io({type:go("createdBank"),parent:wo(),slot:wo(),timestamp:wo()}),Io({type:go("frozen"),slot:wo(),timestamp:wo(),stats:Io({numTransactionEntries:wo(),numSuccessfulTransactions:wo(),numFailedTransactions:wo(),maxTransactionsPerEntry:wo()})}),Io({type:go("dead"),slot:wo(),timestamp:wo(),err:Ao()})]),il=Io({subscription:wo(),result:rl}),ol=Io({subscription:wo(),result:yc(Eo([Ec,xc]))}),al=Io({subscription:wo(),result:wo()}),sl=Io({pubkey:Ao(),gossip:vo(Ao()),tpu:vo(Ao()),rpc:vo(Ao()),version:vo(Ao())}),ul=Io({votePubkey:Ao(),nodePubkey:Ao(),activatedStake:wo(),epochVoteAccount:yo(),epochCredits:po(No([wo(),wo(),wo()])),commission:wo(),lastVote:wo(),rootSlot:vo(wo())}),cl=fc(Io({current:po(ul),delinquent:po(ul)})),ll=Eo([go("processed"),go("confirmed"),go("finalized")]),hl=Io({slot:wo(),confirmations:vo(wo()),err:Ic,confirmationStatus:bo(ll)}),dl=pc(po(vo(hl))),fl=fc(wo()),pl=Io({accountKey:sc,writableIndexes:po(wo()),readonlyIndexes:po(wo())}),yl=Io({signatures:po(Ao()),message:Io({accountKeys:po(Ao()),header:Io({numRequiredSignatures:wo(),numReadonlySignedAccounts:wo(),numReadonlyUnsignedAccounts:wo()}),instructions:po(Io({accounts:po(wo()),data:Ao(),programIdIndex:wo()})),recentBlockhash:Ao(),addressTableLookups:bo(po(pl))})}),ml=Io({pubkey:sc,signer:yo(),writable:yo(),source:bo(Eo([go("transaction"),go("lookupTable")]))}),gl=Io({accountKeys:po(ml),signatures:po(Ao())}),vl=Io({parsed:xo(),program:Ao(),programId:sc}),wl=Io({accounts:po(sc),data:Ao(),programId:sc}),bl=ko(Eo([wl,vl]),Eo([Io({parsed:xo(),program:Ao(),programId:Ao()}),Io({accounts:po(Ao()),data:Ao(),programId:Ao()})]),(function(t){return co(t,"accounts"in t?wl:vl)})),Ml=Io({signatures:po(Ao()),message:Io({accountKeys:po(ml),instructions:po(bl),recentBlockhash:Ao(),addressTableLookups:bo(vo(po(pl)))})}),Al=Io({accountIndex:wo(),mint:Ao(),owner:bo(Ao()),uiTokenAmount:Bc}),Nl=Io({writable:po(sc),readonly:po(sc)}),Il=Io({err:Ic,fee:wo(),innerInstructions:bo(vo(po(Io({index:wo(),instructions:po(Io({accounts:po(wo()),data:Ao(),programIdIndex:wo()}))})))),preBalances:po(wo()),postBalances:po(wo()),logMessages:bo(vo(po(Ao()))),preTokenBalances:bo(vo(po(Al))),postTokenBalances:bo(vo(po(Al))),loadedAddresses:bo(Nl),computeUnitsConsumed:bo(wo())}),El=Io({err:Ic,fee:wo(),innerInstructions:bo(vo(po(Io({index:wo(),instructions:po(bl)})))),preBalances:po(wo()),postBalances:po(wo()),logMessages:bo(vo(po(Ao()))),preTokenBalances:bo(vo(po(Al))),postTokenBalances:bo(vo(po(Al))),loadedAddresses:bo(Nl),computeUnitsConsumed:bo(wo())}),xl=Eo([go(0),go("legacy")]),kl=Io({pubkey:Ao(),lamports:wo(),postBalance:vo(wo()),rewardType:vo(Ao()),commission:bo(vo(wo()))}),Tl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),transactions:po(Io({transaction:yl,meta:vo(Il),version:bo(xl)})),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),Ll=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),Sl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),transactions:po(Io({transaction:gl,meta:vo(Il),version:bo(xl)})),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),jl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),transactions:po(Io({transaction:Ml,meta:vo(El),version:bo(xl)})),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),Cl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),transactions:po(Io({transaction:gl,meta:vo(El),version:bo(xl)})),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),Dl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),rewards:bo(po(kl)),blockTime:vo(wo()),blockHeight:vo(wo())}))),Ol=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),transactions:po(Io({transaction:yl,meta:vo(Il)})),rewards:bo(po(kl)),blockTime:vo(wo())}))),zl=fc(vo(Io({blockhash:Ao(),previousBlockhash:Ao(),parentSlot:wo(),signatures:po(Ao()),blockTime:vo(wo())}))),Pl=fc(vo(Io({slot:wo(),meta:vo(Il),blockTime:bo(vo(wo())),transaction:yl,version:bo(xl)}))),_l=fc(vo(Io({slot:wo(),transaction:Ml,meta:vo(El),blockTime:bo(vo(wo())),version:bo(xl)}))),Bl=pc(Io({blockhash:Ao(),feeCalculator:Io({lamportsPerSignature:wo()})})),Rl=pc(Io({blockhash:Ao(),lastValidBlockHeight:wo()})),Ul=pc(yo()),Ql=fc(po(Io({slot:wo(),numTransactions:wo(),numSlots:wo(),samplePeriodSecs:wo()}))),Yl=pc(vo(Io({feeCalculator:Io({lamportsPerSignature:wo()})}))),Wl=fc(Ao()),Fl=fc(Ao()),Vl=Io({err:Ic,logs:po(Ao()),signature:Ao()}),Hl=Io({result:yc(Vl),subscription:wo()}),Gl={"solana-client":"js/".concat("0.0.0-development")},ql=function(){function t(e,n){var r,i,o,a,s,u,c,l=this;B(this,t),this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(r={},function(){var t=_(O().mark((function t(e){var n,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=lc(e),o=i.commitment,a=i.config,s=l._buildArgs([],o,void 0,a),u=Xu(s),r[u]=null!==(n=r[u])&&void 0!==n?n:_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l._rpcRequest("getBlockHeight",s);case 3:if(e=t.sent,!("error"in(n=co(e,fc(wo()))))){t.next=7;break}throw new ec(n.error,"failed to get block height information");case 7:return t.abrupt("return",n.result);case 8:return t.prev=8,delete r[u],t.finish(8);case 11:case"end":return t.stop()}}),t,null,[[0,,8,11]])})))(),t.next=6,r[u];case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),n&&"string"==typeof n?this._commitment=n:n&&(this._commitment=n.commitment,this._confirmTransactionInitialTimeout=n.confirmTransactionInitialTimeout,i=n.wsEndpoint,o=n.httpHeaders,a=n.fetch,s=n.fetchMiddleware,u=n.disableRetryOnRateLimit,c=n.httpAgent),this._rpcEndpoint=function(t){if(!1===/^https?:/.test(t))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return t}(e),this._rpcWsEndpoint=i||function(t){var e=t.match(ac);if(null==e)throw TypeError("Failed to validate endpoint URL `".concat(t,"`"));var n=tt(e,4);n[0];var r=n[1],i=n[2],o=n[3],a=t.startsWith("https:")?"wss:":"ws:",s=null==i?null:parseInt(i.slice(1),10),u=null==s?"":":".concat(s+1);return"".concat(a,"//").concat(r).concat(u).concat(o)}(e),this._rpcClient=function(t,e,n,r,i,o){var a,s=n||nc;return null!=o&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments."),r&&(a=function(){var t=_(O().mark((function t(e,n){var i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t,i){try{r(e,n,(function(e,n){return t([e,n])}))}catch(t){i(t)}}));case 2:return i=t.sent,t.next=5,s.apply(void 0,et(i));case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),new aa(function(){var n=_(O().mark((function n(r,o){var u,c,l,h,d;return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:u={method:"POST",body:r,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},e||{},Gl)},n.prev=1,c=5,h=500;case 4:if(!a){n.next=10;break}return n.next=7,a(t,u);case 7:l=n.sent,n.next=13;break;case 10:return n.next=12,s(t,u);case 12:l=n.sent;case 13:if(429===l.status){n.next=15;break}return n.abrupt("break",26);case 15:if(!0!==i){n.next=17;break}return n.abrupt("break",26);case 17:if(0!=(c-=1)){n.next=20;break}return n.abrupt("break",26);case 20:return console.log("Server responded with ".concat(l.status," ").concat(l.statusText,". Retrying after ").concat(h,"ms delay...")),n.next=23,Cu(h);case 23:h*=2;case 24:n.next=4;break;case 26:return n.next=28,l.text();case 28:d=n.sent,l.ok?o(null,d):o(new Error("".concat(l.status," ").concat(l.statusText,": ").concat(d))),n.next=35;break;case 32:n.prev=32,n.t0=n.catch(1),n.t0 instanceof Error&&o(n.t0);case 35:case"end":return n.stop()}}),n,null,[[1,32]])})));return function(t,e){return n.apply(this,arguments)}}(),{})}(e,o,a,s,u,c),this._rpcRequest=function(t){return function(e,n){return new Promise((function(r,i){t.request(e,n,(function(t,e){t?i(t):r(e)}))}))}}(this._rpcClient),this._rpcBatchRequest=function(t){return function(e){return new Promise((function(n,r){0===e.length&&n([]);var i=e.map((function(e){return t.request(e.methodName,e.args)}));t.request(i,(function(t,e){t?r(t):n(e)}))}))}}(this._rpcClient),this._rpcWebSocket=new rc(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}var e,n,r,i,o,a,s,u,c,l,h,d,f,p,y,m,g,v,w,b,M,A,N,I,E,x,k,T,L,S,j,C,P,R,Q,Y,W,F,V,H,G,Z,J,X,K,$,nt,rt,it,ot,at,st,ut,ct,lt,ht,dt,ft,pt,yt,mt,gt,vt,wt,bt,Mt,At,Nt,Et,xt,kt,Tt,Lt,St,jt,Ct,Dt,Ot,zt,Pt,_t,Bt,Rt,Ut,Qt,Yt,Wt,Ft,Vt;return U(t,[{key:"commitment",get:function(){return this._commitment}},{key:"rpcEndpoint",get:function(){return this._rpcEndpoint}},{key:"getBalanceAndContext",value:(Vt=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgs([e.toBase58()],i,void 0,o),t.next=4,this._rpcRequest("getBalance",a);case 4:if(s=t.sent,!("error"in(u=co(s,pc(wo()))))){t.next=8;break}throw new ec(u.error,"failed to get balance for ".concat(e.toBase58()));case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return Vt.apply(this,arguments)})},{key:"getBalance",value:(Ft=_(O().mark((function t(e,n){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBalanceAndContext(e,n).then((function(t){return t.value})).catch((function(t){throw new Error("failed to get balance of account "+e.toBase58()+": "+t)}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return Ft.apply(this,arguments)})},{key:"getBlockTime",value:(Wt=_(O().mark((function t(e){var n,r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getBlockTime",[e]);case 2:if(n=t.sent,!("error"in(r=co(n,fc(vo(wo())))))){t.next=6;break}throw new ec(r.error,"failed to get block time for slot ".concat(e));case 6:return t.abrupt("return",r.result);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return Wt.apply(this,arguments)})},{key:"getMinimumLedgerSlot",value:(Yt=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("minimumLedgerSlot",[]);case 2:if(e=t.sent,!("error"in(n=co(e,fc(wo()))))){t.next=6;break}throw new ec(n.error,"failed to get minimum ledger slot");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return Yt.apply(this,arguments)})},{key:"getFirstAvailableBlock",value:(Qt=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getFirstAvailableBlock",[]);case 2:if(e=t.sent,!("error"in(n=co(e,Pc)))){t.next=6;break}throw new ec(n.error,"failed to get first available block");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return Qt.apply(this,arguments)})},{key:"getSupply",value:(Ut=_(O().mark((function t(e){var n,r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={},n="string"==typeof e?{commitment:e}:e?D(D({},e),{},{commitment:e&&e.commitment||this.commitment}):{commitment:this.commitment},t.next=4,this._rpcRequest("getSupply",[n]);case 4:if(r=t.sent,!("error"in(i=co(r,_c)))){t.next=8;break}throw new ec(i.error,"failed to get supply");case 8:return t.abrupt("return",i.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return Ut.apply(this,arguments)})},{key:"getTokenSupply",value:(Rt=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgs([e.toBase58()],n),t.next=3,this._rpcRequest("getTokenSupply",r);case 3:if(i=t.sent,!("error"in(o=co(i,pc(Bc))))){t.next=7;break}throw new ec(o.error,"failed to get token supply");case 7:return t.abrupt("return",o.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return Rt.apply(this,arguments)})},{key:"getTokenAccountBalance",value:(Bt=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgs([e.toBase58()],n),t.next=3,this._rpcRequest("getTokenAccountBalance",r);case 3:if(i=t.sent,!("error"in(o=co(i,pc(Bc))))){t.next=7;break}throw new ec(o.error,"failed to get token account balance");case 7:return t.abrupt("return",o.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return Bt.apply(this,arguments)})},{key:"getTokenAccountsByOwner",value:(_t=_(O().mark((function t(e,n,r){var i,o,a,s,u,c,l;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=lc(r),o=i.commitment,a=i.config,s=[e.toBase58()],"mint"in n?s.push({mint:n.mint.toBase58()}):s.push({programId:n.programId.toBase58()}),u=this._buildArgs(s,o,"base64",a),t.next=6,this._rpcRequest("getTokenAccountsByOwner",u);case 6:if(c=t.sent,!("error"in(l=co(c,Uc)))){t.next=10;break}throw new ec(l.error,"failed to get token accounts owned by account ".concat(e.toBase58()));case 10:return t.abrupt("return",l.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return _t.apply(this,arguments)})},{key:"getParsedTokenAccountsByOwner",value:(Pt=_(O().mark((function t(e,n,r){var i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=[e.toBase58()],"mint"in n?i.push({mint:n.mint.toBase58()}):i.push({programId:n.programId.toBase58()}),o=this._buildArgs(i,r,"jsonParsed"),t.next=5,this._rpcRequest("getTokenAccountsByOwner",o);case 5:if(a=t.sent,!("error"in(s=co(a,Yc)))){t.next=9;break}throw new ec(s.error,"failed to get token accounts owned by account ".concat(e.toBase58()));case 9:return t.abrupt("return",s.result);case 10:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Pt.apply(this,arguments)})},{key:"getLargestAccounts",value:(zt=_(O().mark((function t(e){var n,r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=D(D({},e),{},{commitment:e&&e.commitment||this.commitment}),r=n.filter||n.commitment?[n]:[],t.next=4,this._rpcRequest("getLargestAccounts",r);case 4:if(i=t.sent,!("error"in(o=co(i,Wc)))){t.next=8;break}throw new ec(o.error,"failed to get largest accounts");case 8:return t.abrupt("return",o.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return zt.apply(this,arguments)})},{key:"getTokenLargestAccounts",value:(Ot=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgs([e.toBase58()],n),t.next=3,this._rpcRequest("getTokenLargestAccounts",r);case 3:if(i=t.sent,!("error"in(o=co(i,Rc)))){t.next=7;break}throw new ec(o.error,"failed to get token largest accounts");case 7:return t.abrupt("return",o.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return Ot.apply(this,arguments)})},{key:"getAccountInfoAndContext",value:(Dt=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgs([e.toBase58()],i,"base64",o),t.next=4,this._rpcRequest("getAccountInfo",a);case 4:if(s=t.sent,!("error"in(u=co(s,pc(vo(Fc)))))){t.next=8;break}throw new ec(u.error,"failed to get info about account ".concat(e.toBase58()));case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return Dt.apply(this,arguments)})},{key:"getParsedAccountInfo",value:(Ct=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgs([e.toBase58()],i,"jsonParsed",o),t.next=4,this._rpcRequest("getAccountInfo",a);case 4:if(s=t.sent,!("error"in(u=co(s,pc(vo(Gc)))))){t.next=8;break}throw new ec(u.error,"failed to get info about account ".concat(e.toBase58()));case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return Ct.apply(this,arguments)})},{key:"getAccountInfo",value:(jt=_(O().mark((function t(e,n){var r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getAccountInfoAndContext(e,n);case 3:return r=t.sent,t.abrupt("return",r.value);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("failed to get info about account "+e.toBase58()+": "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(t,e){return jt.apply(this,arguments)})},{key:"getMultipleParsedAccounts",value:(St=_(O().mark((function t(e,n){var r,i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=e.map((function(t){return t.toBase58()})),s=this._buildArgs([a],i,"jsonParsed",o),t.next=5,this._rpcRequest("getMultipleAccounts",s);case 5:if(u=t.sent,!("error"in(c=co(u,pc(po(vo(Gc))))))){t.next=9;break}throw new ec(c.error,"failed to get info for accounts ".concat(a));case 9:return t.abrupt("return",c.result);case 10:case"end":return t.stop()}}),t,this)}))),function(t,e){return St.apply(this,arguments)})},{key:"getMultipleAccountsInfoAndContext",value:(Lt=_(O().mark((function t(e,n){var r,i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=e.map((function(t){return t.toBase58()})),s=this._buildArgs([a],i,"base64",o),t.next=5,this._rpcRequest("getMultipleAccounts",s);case 5:if(u=t.sent,!("error"in(c=co(u,pc(po(vo(Fc))))))){t.next=9;break}throw new ec(c.error,"failed to get info for accounts ".concat(a));case 9:return t.abrupt("return",c.result);case 10:case"end":return t.stop()}}),t,this)}))),function(t,e){return Lt.apply(this,arguments)})},{key:"getMultipleAccountsInfo",value:(Tt=_(O().mark((function t(e,n){var r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getMultipleAccountsInfoAndContext(e,n);case 2:return r=t.sent,t.abrupt("return",r.value);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return Tt.apply(this,arguments)})},{key:"getStakeActivation",value:(kt=_(O().mark((function t(e,n,r){var i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=lc(n),o=i.commitment,a=i.config,s=this._buildArgs([e.toBase58()],o,void 0,D(D({},a),{},{epoch:null!=r?r:null==a?void 0:a.epoch})),t.next=4,this._rpcRequest("getStakeActivation",s);case 4:if(u=t.sent,!("error"in(c=co(u,fc(Zc))))){t.next=8;break}throw new ec(c.error,"failed to get Stake Activation ".concat(e.toBase58()));case 8:return t.abrupt("return",c.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return kt.apply(this,arguments)})},{key:"getProgramAccounts",value:(xt=_(O().mark((function t(e,n){var r,i,o,a,s,u,c,l,h,d;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,s=(a=o||{}).encoding,u=q(a,Ps),c=this._buildArgs([e.toBase58()],i,s||"base64",u),t.next=5,this._rpcRequest("getProgramAccounts",c);case 5:if(l=t.sent,h=po(Vc),!("error"in(d=!0===u.withContext?co(l,pc(h)):co(l,fc(h))))){t.next=10;break}throw new ec(d.error,"failed to get accounts owned by program ".concat(e.toBase58()));case 10:return t.abrupt("return",d.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return xt.apply(this,arguments)})},{key:"getParsedProgramAccounts",value:(Et=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgs([e.toBase58()],i,"jsonParsed",o),t.next=4,this._rpcRequest("getProgramAccounts",a);case 4:if(s=t.sent,!("error"in(u=co(s,fc(po(qc)))))){t.next=8;break}throw new ec(u.error,"failed to get accounts owned by program ".concat(e.toBase58()));case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return Et.apply(this,arguments)})},{key:"confirmTransaction",value:(Nt=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=4;break}r=e,t.next=8;break;case 4:if(null===(i=(o=e).abortSignal)||void 0===i||!i.aborted){t.next=7;break}return t.abrupt("return",Promise.reject(o.abortSignal.reason));case 7:r=o.signature;case 8:t.prev=8,a=dr.decode(r),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(8),new Error("signature must be base58 encoded: "+r);case 15:if(lu(64===a.length,"signature has invalid length"),"string"!=typeof e){t.next=22;break}return t.next=19,this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:n||this.commitment,signature:r});case 19:return t.abrupt("return",t.sent);case 22:if(!("lastValidBlockHeight"in e)){t.next=28;break}return t.next=25,this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:n||this.commitment,strategy:e});case 25:return t.abrupt("return",t.sent);case 28:return t.next=30,this.confirmTransactionUsingDurableNonceStrategy({commitment:n||this.commitment,strategy:e});case 30:return t.abrupt("return",t.sent);case 31:case"end":return t.stop()}}),t,this,[[8,12]])}))),function(t,e){return Nt.apply(this,arguments)})},{key:"getCancellationPromise",value:function(t){return new Promise((function(e,n){null!=t&&(t.aborted?n(t.reason):t.addEventListener("abort",(function(){n(t.reason)})))}))}},{key:"getTransactionConfirmationPromise",value:function(t){var e,n,r=this,i=t.commitment,o=t.signature,a=!1;return{abortConfirmation:function(){n&&(n(),n=void 0),null!=e&&(r.removeSignatureListener(e),e=void 0)},confirmationPromise:new Promise((function(t,s){try{e=r.onSignature(o,(function(n,r){e=void 0;var i={context:r,value:n};t({__type:yu.PROCESSED,response:i})}),i);var u=new Promise((function(t){null==e?t():n=r._onSubscriptionStateChange(e,(function(e){"subscribed"===e&&t()}))}));_(O().mark((function e(){var n,c,l;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u;case 2:if(!a){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,r.getSignatureStatus(o);case 6:if(n=e.sent,!a){e.next=9;break}return e.abrupt("return");case 9:if(null!=n){e.next=11;break}return e.abrupt("return");case 11:if(c=n.context,null!=(l=n.value)){e.next=14;break}return e.abrupt("return");case 14:if(null==l||!l.err){e.next=18;break}s(l.err),e.next=29;break;case 18:e.t0=i,e.next="confirmed"===e.t0||"single"===e.t0||"singleGossip"===e.t0?21:"finalized"===e.t0||"max"===e.t0||"root"===e.t0?24:("processed"===e.t0||e.t0,27);break;case 21:if("processed"!==l.confirmationStatus){e.next=23;break}return e.abrupt("return");case 23:return e.abrupt("break",27);case 24:if("processed"!==l.confirmationStatus&&"confirmed"!==l.confirmationStatus){e.next=26;break}return e.abrupt("return");case 26:return e.abrupt("break",27);case 27:a=!0,t({__type:yu.PROCESSED,response:{context:c,value:l}});case 29:case"end":return e.stop()}}),e)})))()}catch(t){s(t)}}))}}},{key:"confirmTransactionUsingBlockHeightExceedanceStrategy",value:(At=_(O().mark((function t(e){var n,r,i,o,a,s,u,c,l,h,d,f,p,y=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.commitment,r=e.strategy,i=r.abortSignal,o=r.lastValidBlockHeight,a=r.signature,s=!1,u=new Promise((function(t){var e=function(){var t=_(O().mark((function t(){var e;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,y.getBlockHeight(n);case 3:return e=t.sent,t.abrupt("return",e);case 7:return t.prev=7,t.t0=t.catch(0),t.abrupt("return",-1);case 10:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();_(O().mark((function n(){var r;return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e();case 2:if(r=n.sent,!s){n.next=5;break}return n.abrupt("return");case 5:if(!(r<=o)){n.next=17;break}return n.next=8,Cu(1e3);case 8:if(!s){n.next=10;break}return n.abrupt("return");case 10:return n.next=12,e();case 12:if(r=n.sent,!s){n.next=15;break}return n.abrupt("return");case 15:n.next=5;break;case 17:t({__type:yu.BLOCKHEIGHT_EXCEEDED});case 18:case"end":return n.stop()}}),n)})))()})),c=this.getTransactionConfirmationPromise({commitment:n,signature:a}),l=c.abortConfirmation,h=c.confirmationPromise,d=this.getCancellationPromise(i),t.prev=5,t.next=8,Promise.race([d,h,u]);case 8:if((p=t.sent).__type!==yu.PROCESSED){t.next=13;break}f=p.response,t.next=14;break;case 13:throw new tu(a);case 14:return t.prev=14,s=!0,l(),t.finish(14);case 18:return t.abrupt("return",f);case 19:case"end":return t.stop()}}),t,this,[[5,,14,18]])}))),function(t){return At.apply(this,arguments)})},{key:"confirmTransactionUsingDurableNonceStrategy",value:(Mt=_(O().mark((function t(e){var n,r,i,o,a,s,u,c,l,h,d,f,p,y,m,g,v,w,b,M,A,N=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.commitment,r=e.strategy,i=r.abortSignal,o=r.minContextSlot,a=r.nonceAccountPubkey,s=r.nonceValue,u=r.signature,c=!1,l=new Promise((function(t){var e=s,r=null,i=function(){var t=_(O().mark((function t(){var i,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,N.getNonceAndContext(a,{commitment:n,minContextSlot:o});case 3:return i=t.sent,s=i.context,u=i.value,r=s.slot,t.abrupt("return",null==u?void 0:u.nonce);case 10:return t.prev=10,t.t0=t.catch(0),t.abrupt("return",e);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(){return t.apply(this,arguments)}}();_(O().mark((function n(){return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,i();case 2:if(e=n.sent,!c){n.next=5;break}return n.abrupt("return");case 5:if(s===e){n.next=9;break}return t({__type:yu.NONCE_INVALID,slotInWhichNonceDidAdvance:r}),n.abrupt("return");case 9:return n.next=11,Cu(2e3);case 11:if(!c){n.next=13;break}return n.abrupt("return");case 13:return n.next=15,i();case 15:if(e=n.sent,!c){n.next=18;break}return n.abrupt("return");case 18:n.next=5;break;case 20:case"end":return n.stop()}}),n)})))()})),h=this.getTransactionConfirmationPromise({commitment:n,signature:u}),d=h.abortConfirmation,f=h.confirmationPromise,p=this.getCancellationPromise(i),t.prev=5,t.next=8,Promise.race([p,f,l]);case 8:if((m=t.sent).__type!==yu.PROCESSED){t.next=13;break}y=m.response,t.next=47;break;case 13:return t.next=16,this.getSignatureStatus(u);case 16:if(null!=(b=t.sent)){t.next=19;break}return t.abrupt("break",27);case 19:if(!(b.context.slot<(null!==(w=m.slotInWhichNonceDidAdvance)&&void 0!==w?w:o))){t.next=23;break}return t.next=22,Cu(400);case 22:return t.abrupt("continue",13);case 23:return v=b,t.abrupt("break",27);case 27:if(null===(g=v)||void 0===g||!g.value){t.next=46;break}M=n||"finalized",A=v.value.confirmationStatus,t.t0=M,t.next="processed"===t.t0||"recent"===t.t0?33:"confirmed"===t.t0||"single"===t.t0||"singleGossip"===t.t0?36:"finalized"===t.t0||"max"===t.t0||"root"===t.t0?39:42;break;case 33:if("processed"===A||"confirmed"===A||"finalized"===A){t.next=35;break}throw new nu(u);case 35:return t.abrupt("break",43);case 36:if("confirmed"===A||"finalized"===A){t.next=38;break}throw new nu(u);case 38:return t.abrupt("break",43);case 39:if("finalized"===A){t.next=41;break}throw new nu(u);case 41:return t.abrupt("break",43);case 42:case 43:y={context:v.context,value:{err:v.value.err}},t.next=47;break;case 46:throw new nu(u);case 47:return t.prev=47,c=!0,d(),t.finish(47);case 51:return t.abrupt("return",y);case 52:case"end":return t.stop()}}),t,this,[[5,,47,51]])}))),function(t){return Mt.apply(this,arguments)})},{key:"confirmTransactionUsingLegacyTimeoutStrategy",value:(bt=_(O().mark((function t(e){var n,r,i,o,a,s,u,c,l,h=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.commitment,r=e.signature,o=new Promise((function(t){var e=h._confirmTransactionInitialTimeout||6e4;switch(n){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":e=h._confirmTransactionInitialTimeout||3e4}i=setTimeout((function(){return t({__type:yu.TIMED_OUT,timeoutMs:e})}),e)})),a=this.getTransactionConfirmationPromise({commitment:n,signature:r}),s=a.abortConfirmation,u=a.confirmationPromise,t.prev=3,t.next=6,Promise.race([u,o]);case 6:if((l=t.sent).__type!==yu.PROCESSED){t.next=11;break}c=l.response,t.next=12;break;case 11:throw new eu(r,l.timeoutMs/1e3);case 12:return t.prev=12,clearTimeout(i),s(),t.finish(12);case 16:return t.abrupt("return",c);case 17:case"end":return t.stop()}}),t,this,[[3,,12,16]])}))),function(t){return bt.apply(this,arguments)})},{key:"getClusterNodes",value:(wt=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getClusterNodes",[]);case 2:if(e=t.sent,!("error"in(n=co(e,fc(po(sl)))))){t.next=6;break}throw new ec(n.error,"failed to get cluster nodes");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return wt.apply(this,arguments)})},{key:"getVoteAccounts",value:(vt=_(O().mark((function t(e){var n,r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._buildArgs([],e),t.next=3,this._rpcRequest("getVoteAccounts",n);case 3:if(r=t.sent,!("error"in(i=co(r,cl)))){t.next=7;break}throw new ec(i.error,"failed to get vote accounts");case 7:return t.abrupt("return",i.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return vt.apply(this,arguments)})},{key:"getSlot",value:(gt=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,void 0,i),t.next=4,this._rpcRequest("getSlot",o);case 4:if(a=t.sent,!("error"in(s=co(a,fc(wo()))))){t.next=8;break}throw new ec(s.error,"failed to get slot");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return gt.apply(this,arguments)})},{key:"getSlotLeader",value:(mt=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,void 0,i),t.next=4,this._rpcRequest("getSlotLeader",o);case 4:if(a=t.sent,!("error"in(s=co(a,fc(Ao()))))){t.next=8;break}throw new ec(s.error,"failed to get slot leader");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return mt.apply(this,arguments)})},{key:"getSlotLeaders",value:(yt=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[e,n],t.next=3,this._rpcRequest("getSlotLeaders",r);case 3:if(i=t.sent,!("error"in(o=co(i,fc(po(sc)))))){t.next=7;break}throw new ec(o.error,"failed to get slot leaders");case 7:return t.abrupt("return",o.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return yt.apply(this,arguments)})},{key:"getSignatureStatus",value:(pt=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSignatureStatuses([e],n);case 2:return r=t.sent,i=r.context,lu(1===(o=r.value).length),a=o[0],t.abrupt("return",{context:i,value:a});case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return pt.apply(this,arguments)})},{key:"getSignatureStatuses",value:(ft=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[e],n&&r.push(n),t.next=4,this._rpcRequest("getSignatureStatuses",r);case 4:if(i=t.sent,!("error"in(o=co(i,dl)))){t.next=8;break}throw new ec(o.error,"failed to get signature status");case 8:return t.abrupt("return",o.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return ft.apply(this,arguments)})},{key:"getTransactionCount",value:(dt=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,void 0,i),t.next=4,this._rpcRequest("getTransactionCount",o);case 4:if(a=t.sent,!("error"in(s=co(a,fc(wo()))))){t.next=8;break}throw new ec(s.error,"failed to get transaction count");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return dt.apply(this,arguments)})},{key:"getTotalSupply",value:(ht=_(O().mark((function t(e){var n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0});case 2:return n=t.sent,t.abrupt("return",n.value.total);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return ht.apply(this,arguments)})},{key:"getInflationGovernor",value:(lt=_(O().mark((function t(e){var n,r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._buildArgs([],e),t.next=3,this._rpcRequest("getInflationGovernor",n);case 3:if(r=t.sent,!("error"in(i=co(r,Sc)))){t.next=7;break}throw new ec(i.error,"failed to get inflation");case 7:return t.abrupt("return",i.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return lt.apply(this,arguments)})},{key:"getInflationReward",value:(ct=_(O().mark((function t(e,n,r){var i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=lc(r),o=i.commitment,a=i.config,s=this._buildArgs([e.map((function(t){return t.toBase58()}))],o,void 0,D(D({},a),{},{epoch:null!=n?n:null==a?void 0:a.epoch})),t.next=4,this._rpcRequest("getInflationReward",s);case 4:if(u=t.sent,!("error"in(c=co(u,vc)))){t.next=8;break}throw new ec(c.error,"failed to get inflation reward");case 8:return t.abrupt("return",c.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return ct.apply(this,arguments)})},{key:"getInflationRate",value:(ut=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getInflationRate",[]);case 2:if(e=t.sent,!("error"in(n=co(e,jc)))){t.next=6;break}throw new ec(n.error,"failed to get inflation rate");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return ut.apply(this,arguments)})},{key:"getEpochInfo",value:(st=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,void 0,i),t.next=4,this._rpcRequest("getEpochInfo",o);case 4:if(a=t.sent,!("error"in(s=co(a,Dc)))){t.next=8;break}throw new ec(s.error,"failed to get epoch info");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return st.apply(this,arguments)})},{key:"getEpochSchedule",value:(at=_(O().mark((function t(){var e,n,r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getEpochSchedule",[]);case 2:if(e=t.sent,!("error"in(n=co(e,Oc)))){t.next=6;break}throw new ec(n.error,"failed to get epoch schedule");case 6:return r=n.result,t.abrupt("return",new $u(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot));case 8:case"end":return t.stop()}}),t,this)}))),function(){return at.apply(this,arguments)})},{key:"getLeaderSchedule",value:(ot=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getLeaderSchedule",[]);case 2:if(e=t.sent,!("error"in(n=co(e,zc)))){t.next=6;break}throw new ec(n.error,"failed to get leader schedule");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return ot.apply(this,arguments)})},{key:"getMinimumBalanceForRentExemption",value:(it=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgs([e],n),t.next=3,this._rpcRequest("getMinimumBalanceForRentExemption",r);case 3:if(i=t.sent,!("error"in(o=co(i,fl)))){t.next=8;break}return console.warn("Unable to fetch minimum balance for rent exemption"),t.abrupt("return",0);case 8:return t.abrupt("return",o.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return it.apply(this,arguments)})},{key:"getRecentBlockhashAndContext",value:(rt=_(O().mark((function t(e){var n,r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this._buildArgs([],e),t.next=3,this._rpcRequest("getRecentBlockhash",n);case 3:if(r=t.sent,!("error"in(i=co(r,Bl)))){t.next=7;break}throw new ec(i.error,"failed to get recent blockhash");case 7:return t.abrupt("return",i.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t){return rt.apply(this,arguments)})},{key:"getRecentPerformanceSamples",value:(nt=_(O().mark((function t(e){var n,r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]);case 2:if(n=t.sent,!("error"in(r=co(n,Ql)))){t.next=6;break}throw new ec(r.error,"failed to get recent performance samples");case 6:return t.abrupt("return",r.result);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return nt.apply(this,arguments)})},{key:"getFeeCalculatorForBlockhash",value:($=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgs([e],n),t.next=3,this._rpcRequest("getFeeCalculatorForBlockhash",r);case 3:if(i=t.sent,!("error"in(o=co(i,Yl)))){t.next=7;break}throw new ec(o.error,"failed to get fee calculator");case 7:return a=o.result,s=a.context,u=a.value,t.abrupt("return",{context:s,value:null!==u?u.feeCalculator:null});case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return $.apply(this,arguments)})},{key:"getFeeForMessage",value:(K=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Hs(e.serialize()).toString("base64"),i=this._buildArgs([r],n),t.next=4,this._rpcRequest("getFeeForMessage",i);case 4:if(o=t.sent,!("error"in(a=co(o,pc(vo(wo())))))){t.next=8;break}throw new ec(a.error,"failed to get fee for message");case 8:if(null!==a.result){t.next=10;break}throw new Error("invalid blockhash");case 10:return t.abrupt("return",a.result);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return K.apply(this,arguments)})},{key:"getRecentPrioritizationFees",value:(X=_(O().mark((function t(e){var n,r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=null==e||null===(n=e.lockedWritableAccounts)||void 0===n?void 0:n.map((function(t){return t.toBase58()})),i=null!=r&&r.length?[r]:[],t.next=4,this._rpcRequest("getRecentPrioritizationFees",i);case 4:if(o=t.sent,!("error"in(a=co(o,Cc)))){t.next=8;break}throw new ec(a.error,"failed to get recent prioritization fees");case 8:return t.abrupt("return",a.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return X.apply(this,arguments)})},{key:"getRecentBlockhash",value:(J=_(O().mark((function t(e){var n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getRecentBlockhashAndContext(e);case 3:return n=t.sent,t.abrupt("return",n.value);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("failed to get recent blockhash: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(t){return J.apply(this,arguments)})},{key:"getLatestBlockhash",value:(Z=_(O().mark((function t(e){var n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getLatestBlockhashAndContext(e);case 3:return n=t.sent,t.abrupt("return",n.value);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("failed to get recent blockhash: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(t){return Z.apply(this,arguments)})},{key:"getLatestBlockhashAndContext",value:(G=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,void 0,i),t.next=4,this._rpcRequest("getLatestBlockhash",o);case 4:if(a=t.sent,!("error"in(s=co(a,Rl)))){t.next=8;break}throw new ec(s.error,"failed to get latest blockhash");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return G.apply(this,arguments)})},{key:"isBlockhashValid",value:(H=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgs([e],i,void 0,o),t.next=4,this._rpcRequest("isBlockhashValid",a);case 4:if(s=t.sent,!("error"in(u=co(s,Ul)))){t.next=8;break}throw new ec(u.error,"failed to determine if the blockhash `"+e+"`is valid");case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return H.apply(this,arguments)})},{key:"getVersion",value:(V=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getVersion",[]);case 2:if(e=t.sent,!("error"in(n=co(e,fc(kc))))){t.next=6;break}throw new ec(n.error,"failed to get version");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return V.apply(this,arguments)})},{key:"getGenesisHash",value:(F=_(O().mark((function t(){var e,n;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("getGenesisHash",[]);case 2:if(e=t.sent,!("error"in(n=co(e,fc(Ao()))))){t.next=6;break}throw new ec(n.error,"failed to get genesis hash");case 6:return t.abrupt("return",n.result);case 7:case"end":return t.stop()}}),t,this)}))),function(){return F.apply(this,arguments)})},{key:"getBlock",value:(W=_(O().mark((function t(e,n){var r,i,o,a,s,u,c,l,h;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgsAtLeastConfirmed([e],i,void 0,o),t.next=4,this._rpcRequest("getBlock",a);case 4:s=t.sent,t.prev=5,t.t0=null==o?void 0:o.transactionDetails,t.next="accounts"===t.t0?9:"none"===t.t0?13:17;break;case 9:if(!("error"in(u=co(s,Sl)))){t.next=12;break}throw u.error;case 12:return t.abrupt("return",u.result);case 13:if(!("error"in(c=co(s,Ll)))){t.next=16;break}throw c.error;case 16:return t.abrupt("return",c.result);case 17:if(!("error"in(l=co(s,Tl)))){t.next=20;break}throw l.error;case 20:return h=l.result,t.abrupt("return",h?D(D({},h),{},{transactions:h.transactions.map((function(t){var e=t.transaction,n=t.meta,r=t.version;return{meta:n,transaction:D(D({},e),{},{message:mc(r,e.message)}),version:r}}))}):null);case 22:t.next=27;break;case 24:throw t.prev=24,t.t1=t.catch(5),new ec(t.t1,"failed to get confirmed block");case 27:case"end":return t.stop()}}),t,this,[[5,24]])}))),function(t,e){return W.apply(this,arguments)})},{key:"getParsedBlock",value:(Y=_(O().mark((function t(e,n){var r,i,o,a,s,u,c,l;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgsAtLeastConfirmed([e],i,"jsonParsed",o),t.next=4,this._rpcRequest("getBlock",a);case 4:s=t.sent,t.prev=5,t.t0=null==o?void 0:o.transactionDetails,t.next="accounts"===t.t0?9:"none"===t.t0?13:17;break;case 9:if(!("error"in(u=co(s,Cl)))){t.next=12;break}throw u.error;case 12:return t.abrupt("return",u.result);case 13:if(!("error"in(c=co(s,Dl)))){t.next=16;break}throw c.error;case 16:return t.abrupt("return",c.result);case 17:if(!("error"in(l=co(s,jl)))){t.next=20;break}throw l.error;case 20:return t.abrupt("return",l.result);case 21:t.next=26;break;case 23:throw t.prev=23,t.t1=t.catch(5),new ec(t.t1,"failed to get block");case 26:case"end":return t.stop()}}),t,this,[[5,23]])}))),function(t,e){return Y.apply(this,arguments)})},{key:"getBlockProduction",value:(Q=_(O().mark((function t(e){var n,r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e?r=e:e&&(i=e.commitment,o=q(e,_s),r=i,n=o),a=this._buildArgs([],r,"base64",n),t.next=4,this._rpcRequest("getBlockProduction",a);case 4:if(s=t.sent,!("error"in(u=co(s,Lc)))){t.next=8;break}throw new ec(u.error,"failed to get block production information");case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return Q.apply(this,arguments)})},{key:"getTransaction",value:(R=_(O().mark((function t(e,n){var r,i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgsAtLeastConfirmed([e],i,void 0,o),t.next=4,this._rpcRequest("getTransaction",a);case 4:if(s=t.sent,!("error"in(u=co(s,Pl)))){t.next=8;break}throw new ec(u.error,"failed to get transaction");case 8:if(c=u.result){t.next=11;break}return t.abrupt("return",c);case 11:return t.abrupt("return",D(D({},c),{},{transaction:D(D({},c.transaction),{},{message:mc(c.version,c.transaction.message)})}));case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return R.apply(this,arguments)})},{key:"getParsedTransaction",value:(P=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=this._buildArgsAtLeastConfirmed([e],i,"jsonParsed",o),t.next=4,this._rpcRequest("getTransaction",a);case 4:if(s=t.sent,!("error"in(u=co(s,_l)))){t.next=8;break}throw new ec(u.error,"failed to get transaction");case 8:return t.abrupt("return",u.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t,e){return P.apply(this,arguments)})},{key:"getParsedTransactions",value:(C=_(O().mark((function t(e,n){var r,i,o,a,s,u,c=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=e.map((function(t){return{methodName:"getTransaction",args:c._buildArgsAtLeastConfirmed([t],i,"jsonParsed",o)}})),t.next=4,this._rpcBatchRequest(a);case 4:return s=t.sent,u=s.map((function(t){var e=co(t,_l);if("error"in e)throw new ec(e.error,"failed to get transactions");return e.result})),t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return C.apply(this,arguments)})},{key:"getTransactions",value:(j=_(O().mark((function t(e,n){var r,i,o,a,s,u,c=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=lc(n),i=r.commitment,o=r.config,a=e.map((function(t){return{methodName:"getTransaction",args:c._buildArgsAtLeastConfirmed([t],i,void 0,o)}})),t.next=4,this._rpcBatchRequest(a);case 4:return s=t.sent,u=s.map((function(t){var e=co(t,Pl);if("error"in e)throw new ec(e.error,"failed to get transactions");var n=e.result;return n?D(D({},n),{},{transaction:D(D({},n.transaction),{},{message:mc(n.version,n.transaction.message)})}):n})),t.abrupt("return",u);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return j.apply(this,arguments)})},{key:"getConfirmedBlock",value:(S=_(O().mark((function t(e,n){var r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgsAtLeastConfirmed([e],n),t.next=3,this._rpcRequest("getConfirmedBlock",r);case 3:if(i=t.sent,!("error"in(o=co(i,Ol)))){t.next=7;break}throw new ec(o.error,"failed to get confirmed block");case 7:if(a=o.result){t.next=10;break}throw new Error("Confirmed block "+e+" not found");case 10:return s=D(D({},a),{},{transactions:a.transactions.map((function(t){var e=t.transaction,n=t.meta,r=new du(e.message);return{meta:n,transaction:D(D({},e),{},{message:r})}}))}),t.abrupt("return",D(D({},s),{},{transactions:s.transactions.map((function(t){var e=t.transaction;return{meta:t.meta,transaction:vu.populate(e.message,e.signatures)}}))}));case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return S.apply(this,arguments)})},{key:"getBlocks",value:(L=_(O().mark((function t(e,n,r){var i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._buildArgsAtLeastConfirmed(void 0!==n?[e,n]:[e],r),t.next=3,this._rpcRequest("getBlocks",i);case 3:if(o=t.sent,!("error"in(a=co(o,fc(po(wo())))))){t.next=7;break}throw new ec(a.error,"failed to get blocks");case 7:return t.abrupt("return",a.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return L.apply(this,arguments)})},{key:"getBlockSignatures",value:(T=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgsAtLeastConfirmed([e],n,void 0,{transactionDetails:"signatures",rewards:!1}),t.next=3,this._rpcRequest("getBlock",r);case 3:if(i=t.sent,!("error"in(o=co(i,zl)))){t.next=7;break}throw new ec(o.error,"failed to get block");case 7:if(a=o.result){t.next=10;break}throw new Error("Block "+e+" not found");case 10:return t.abrupt("return",a);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return T.apply(this,arguments)})},{key:"getConfirmedBlockSignatures",value:(k=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgsAtLeastConfirmed([e],n,void 0,{transactionDetails:"signatures",rewards:!1}),t.next=3,this._rpcRequest("getConfirmedBlock",r);case 3:if(i=t.sent,!("error"in(o=co(i,zl)))){t.next=7;break}throw new ec(o.error,"failed to get confirmed block");case 7:if(a=o.result){t.next=10;break}throw new Error("Confirmed block "+e+" not found");case 10:return t.abrupt("return",a);case 11:case"end":return t.stop()}}),t,this)}))),function(t,e){return k.apply(this,arguments)})},{key:"getConfirmedTransaction",value:(x=_(O().mark((function t(e,n){var r,i,o,a,s,u;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgsAtLeastConfirmed([e],n),t.next=3,this._rpcRequest("getConfirmedTransaction",r);case 3:if(i=t.sent,!("error"in(o=co(i,Pl)))){t.next=7;break}throw new ec(o.error,"failed to get transaction");case 7:if(a=o.result){t.next=10;break}return t.abrupt("return",a);case 10:return s=new du(a.transaction.message),u=a.transaction.signatures,t.abrupt("return",D(D({},a),{},{transaction:vu.populate(s,u)}));case 13:case"end":return t.stop()}}),t,this)}))),function(t,e){return x.apply(this,arguments)})},{key:"getParsedConfirmedTransaction",value:(E=_(O().mark((function t(e,n){var r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed"),t.next=3,this._rpcRequest("getConfirmedTransaction",r);case 3:if(i=t.sent,!("error"in(o=co(i,_l)))){t.next=7;break}throw new ec(o.error,"failed to get confirmed transaction");case 7:return t.abrupt("return",o.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return E.apply(this,arguments)})},{key:"getParsedConfirmedTransactions",value:(I=_(O().mark((function t(e,n){var r,i,o,a=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{methodName:"getConfirmedTransaction",args:a._buildArgsAtLeastConfirmed([t],n,"jsonParsed")}})),t.next=3,this._rpcBatchRequest(r);case 3:return i=t.sent,o=i.map((function(t){var e=co(t,_l);if("error"in e)throw new ec(e.error,"failed to get confirmed transactions");return e.result})),t.abrupt("return",o);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e){return I.apply(this,arguments)})},{key:"getConfirmedSignaturesForAddress",value:(N=_(O().mark((function t(e,n,r){var i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={},t.next=3,this.getFirstAvailableBlock();case 3:o=t.sent;case 4:if("until"in i){t.next=24;break}if(!(--n<=0||n0&&(i.until=a.signatures[a.signatures.length-1].toString()),t.next=22;break;case 15:if(t.prev=15,t.t0=t.catch(8),!(t.t0 instanceof Error&&t.t0.message.includes("skipped"))){t.next=21;break}return t.abrupt("continue",4);case 21:throw t.t0;case 22:t.next=4;break;case 24:return t.next=26,this.getSlot("finalized");case 26:s=t.sent;case 27:if("before"in i){t.next=47;break}if(!(++r>s)){t.next=31;break}return t.abrupt("break",47);case 31:return t.prev=31,t.next=34,this.getConfirmedBlockSignatures(r);case 34:(u=t.sent).signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString()),t.next=45;break;case 38:if(t.prev=38,t.t1=t.catch(31),!(t.t1 instanceof Error&&t.t1.message.includes("skipped"))){t.next=44;break}return t.abrupt("continue",27);case 44:throw t.t1;case 45:t.next=27;break;case 47:return t.next=49,this.getConfirmedSignaturesForAddress2(e,i);case 49:return c=t.sent,t.abrupt("return",c.map((function(t){return t.signature})));case 51:case"end":return t.stop()}}),t,this,[[8,15],[31,38]])}))),function(t,e,n){return N.apply(this,arguments)})},{key:"getConfirmedSignaturesForAddress2",value:(A=_(O().mark((function t(e,n,r){var i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,n),t.next=3,this._rpcRequest("getConfirmedSignaturesForAddress2",i);case 3:if(o=t.sent,!("error"in(a=co(o,Jc)))){t.next=7;break}throw new ec(a.error,"failed to get confirmed signatures for address");case 7:return t.abrupt("return",a.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return A.apply(this,arguments)})},{key:"getSignaturesForAddress",value:(M=_(O().mark((function t(e,n,r){var i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,n),t.next=3,this._rpcRequest("getSignaturesForAddress",i);case 3:if(o=t.sent,!("error"in(a=co(o,Xc)))){t.next=7;break}throw new ec(a.error,"failed to get signatures for address");case 7:return t.abrupt("return",a.result);case 8:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return M.apply(this,arguments)})},{key:"getAddressLookupTable",value:(b=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountInfoAndContext(e,n);case 2:return r=t.sent,i=r.context,o=r.value,a=null,null!==o&&(a=new ic({key:e,state:ic.deserialize(o.data)})),t.abrupt("return",{context:i,value:a});case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return b.apply(this,arguments)})},{key:"getNonceAndContext",value:(w=_(O().mark((function t(e,n){var r,i,o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAccountInfoAndContext(e,n);case 2:return r=t.sent,i=r.context,o=r.value,a=null,null!==o&&(a=Ru.fromAccountData(o.data)),t.abrupt("return",{context:i,value:a});case 8:case"end":return t.stop()}}),t,this)}))),function(t,e){return w.apply(this,arguments)})},{key:"getNonce",value:(v=_(O().mark((function t(e,n){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getNonceAndContext(e,n).then((function(t){return t.value})).catch((function(t){throw new Error("failed to get nonce for account "+e.toBase58()+": "+t)}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e){return v.apply(this,arguments)})},{key:"requestAirdrop",value:(g=_(O().mark((function t(e,n){var r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._rpcRequest("requestAirdrop",[e.toBase58(),n]);case 2:if(r=t.sent,!("error"in(i=co(r,Wl)))){t.next=6;break}throw new ec(i.error,"airdrop to ".concat(e.toBase58()," failed"));case 6:return t.abrupt("return",i.result);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return g.apply(this,arguments)})},{key:"_blockhashWithExpiryBlockHeight",value:(m=_(O().mark((function t(e){var n,r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=10;break}case 1:if(!this._pollingBlockhash){t.next=6;break}return t.next=4,Cu(100);case 4:t.next=1;break;case 6:if(n=Date.now()-this._blockhashInfo.lastFetch,r=n>=3e4,null===this._blockhashInfo.latestBlockhash||r){t.next=10;break}return t.abrupt("return",this._blockhashInfo.latestBlockhash);case 10:return t.next=12,this._pollNewBlockhash();case 12:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),t,this)}))),function(t){return m.apply(this,arguments)})},{key:"_pollNewBlockhash",value:(y=_(O().mark((function t(){var e,n,r,i,o;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._pollingBlockhash=!0,t.prev=1,e=Date.now(),n=this._blockhashInfo.latestBlockhash,r=n?n.blockhash:null,i=0;case 6:if(!(i<50)){t.next=18;break}return t.next=9,this.getLatestBlockhash("finalized");case 9:if(o=t.sent,r===o.blockhash){t.next=13;break}return this._blockhashInfo={latestBlockhash:o,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},t.abrupt("return",o);case 13:return t.next=15,Cu(200);case 15:i++,t.next=6;break;case 18:throw new Error("Unable to obtain a new blockhash after ".concat(Date.now()-e,"ms"));case 19:return t.prev=19,this._pollingBlockhash=!1,t.finish(19);case 22:case"end":return t.stop()}}),t,this,[[1,,19,22]])}))),function(){return y.apply(this,arguments)})},{key:"getStakeMinimumDelegation",value:(p=_(O().mark((function t(e){var n,r,i,o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=lc(e),r=n.commitment,i=n.config,o=this._buildArgs([],r,"base64",i),t.next=4,this._rpcRequest("getStakeMinimumDelegation",o);case 4:if(a=t.sent,!("error"in(s=co(a,pc(wo()))))){t.next=8;break}throw new ec(s.error,"failed to get stake minimum delegation");case 8:return t.abrupt("return",s.result);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"simulateTransaction",value:(f=_(O().mark((function t(e,n,r){var i,o,a,s,u,c,l,h,d,f,p,y,m,g,v,w,b,M,A,N,I,E,x,k,T,L;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("message"in e)){t.next=17;break}if(i=e.serialize(),o=It.from(i).toString("base64"),!Array.isArray(n)&&void 0===r){t.next=6;break}throw new Error("Invalid arguments");case 6:return(a=n||{}).encoding="base64","commitment"in a||(a.commitment=this.commitment),s=[o,a],t.next=12,this._rpcRequest("simulateTransaction",s);case 12:if(u=t.sent,!("error"in(c=co(u,Tc)))){t.next=16;break}throw new Error("failed to simulate transaction: "+c.error.message);case 16:return t.abrupt("return",c.result);case 17:if(e instanceof vu?(h=e,(l=new vu).feePayer=h.feePayer,l.instructions=e.instructions,l.nonceInfo=h.nonceInfo,l.signatures=h.signatures):(l=vu.populate(e))._message=l._json=void 0,void 0===n||Array.isArray(n)){t.next=20;break}throw new Error("Invalid arguments");case 20:if(d=n,!l.nonceInfo||!d){t.next=25;break}(f=l).sign.apply(f,et(d)),t.next=45;break;case 25:p=this._disableBlockhashCaching;case 26:return t.next=28,this._blockhashWithExpiryBlockHeight(p);case 28:if(m=t.sent,l.lastValidBlockHeight=m.lastValidBlockHeight,l.recentBlockhash=m.blockhash,d){t.next=33;break}return t.abrupt("break",45);case 33:if((y=l).sign.apply(y,et(d)),l.signature){t.next=36;break}throw new Error("!signature");case 36:if(g=l.signature.toString("base64"),this._blockhashInfo.simulatedSignatures.includes(g)||this._blockhashInfo.transactionSignatures.includes(g)){t.next=42;break}return this._blockhashInfo.simulatedSignatures.push(g),t.abrupt("break",45);case 42:p=!0;case 43:t.next=26;break;case 45:return v=l._compile(),w=v.serialize(),b=l._serialize(w),M=b.toString("base64"),A={encoding:"base64",commitment:this.commitment},r&&(N=(Array.isArray(r)?r:v.nonProgramIds()).map((function(t){return t.toBase58()})),A.accounts={encoding:"base64",addresses:N}),d&&(A.sigVerify=!0),I=[M,A],t.next=55,this._rpcRequest("simulateTransaction",I);case 55:if(E=t.sent,!("error"in(x=co(E,Tc)))){t.next=60;break}throw"data"in x.error&&(k=x.error.data.logs)&&Array.isArray(k)&&(L=(T="\n ")+k.join(T),console.error(x.error.message,L)),new tc("failed to simulate transaction: "+x.error.message,k);case 60:return t.abrupt("return",x.result);case 61:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return f.apply(this,arguments)})},{key:"sendTransaction",value:(d=_(O().mark((function t(e,n,r){var i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!("version"in e)){t.next=7;break}if(!n||!Array.isArray(n)){t.next=3;break}throw new Error("Invalid arguments");case 3:return i=e.serialize(),t.next=6,this.sendRawTransaction(i,n);case 6:return t.abrupt("return",t.sent);case 7:if(void 0!==n&&Array.isArray(n)){t.next=9;break}throw new Error("Invalid arguments");case 9:if(o=n,!e.nonceInfo){t.next=14;break}e.sign.apply(e,et(o)),t.next=32;break;case 14:a=this._disableBlockhashCaching;case 15:return t.next=17,this._blockhashWithExpiryBlockHeight(a);case 17:if(s=t.sent,e.lastValidBlockHeight=s.lastValidBlockHeight,e.recentBlockhash=s.blockhash,e.sign.apply(e,et(o)),e.signature){t.next=23;break}throw new Error("!signature");case 23:if(u=e.signature.toString("base64"),this._blockhashInfo.transactionSignatures.includes(u)){t.next=29;break}return this._blockhashInfo.transactionSignatures.push(u),t.abrupt("break",32);case 29:a=!0;case 30:t.next=15;break;case 32:return c=e.serialize(),t.next=35,this.sendRawTransaction(c,r);case 35:return t.abrupt("return",t.sent);case 36:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return d.apply(this,arguments)})},{key:"sendRawTransaction",value:(h=_(O().mark((function t(e,n){var r,i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Hs(e).toString("base64"),t.next=3,this.sendEncodedTransaction(r,n);case 3:return i=t.sent,t.abrupt("return",i);case 5:case"end":return t.stop()}}),t,this)}))),function(t,e){return h.apply(this,arguments)})},{key:"sendEncodedTransaction",value:(l=_(O().mark((function t(e,n){var r,i,o,a,s,u,c;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={encoding:"base64"},i=n&&n.skipPreflight,o=n&&n.preflightCommitment||this.commitment,n&&null!=n.maxRetries&&(r.maxRetries=n.maxRetries),n&&null!=n.minContextSlot&&(r.minContextSlot=n.minContextSlot),i&&(r.skipPreflight=i),o&&(r.preflightCommitment=o),a=[e,r],t.next=10,this._rpcRequest("sendTransaction",a);case 10:if(s=t.sent,!("error"in(u=co(s,Fl)))){t.next=15;break}throw"data"in u.error&&(c=u.error.data.logs),new tc("failed to send transaction: "+u.error.message,c);case 15:return t.abrupt("return",u.result);case 16:case"end":return t.stop()}}),t,this)}))),function(t,e){return l.apply(this,arguments)})},{key:"_wsOnOpen",value:function(){var t=this;this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((function(){_(O().mark((function e(){return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t._rpcWebSocket.notify("ping");case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:case"end":return e.stop()}}),e,null,[[0,5]])})))()}),5e3),this._updateSubscriptions()}},{key:"_wsOnError",value:function(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}},{key:"_wsOnClose",value:function(t){var e=this;this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3!==t?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((function(t){var n=tt(t,2),r=n[0],i=n[1];e._setSubscription(r,D(D({},i),{},{state:"pending"}))}))):this._updateSubscriptions()}},{key:"_setSubscription",value:function(t,e){var n,r=null===(n=this._subscriptionsByHash[t])||void 0===n?void 0:n.state;if(this._subscriptionsByHash[t]=e,r!==e.state){var i=this._subscriptionStateChangeCallbacksByHash[t];i&&i.forEach((function(t){try{t(e.state)}catch(t){}}))}}},{key:"_onSubscriptionStateChange",value:function(t,e){var n,r=this,i=this._subscriptionHashByClientSubscriptionId[t];if(null==i)return function(){};var o=(n=this._subscriptionStateChangeCallbacksByHash)[i]||(n[i]=new Set);return o.add(e),function(){o.delete(e),0===o.size&&delete r._subscriptionStateChangeCallbacksByHash[i]}}},{key:"_updateSubscriptions",value:(c=_(O().mark((function t(){var e,n,r=this;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==Object.keys(this._subscriptionsByHash).length){t.next=3;break}return this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout((function(){r._rpcWebSocketIdleTimeout=null;try{r._rpcWebSocket.close()}catch(t){t instanceof Error&&console.log("Error when closing socket connection: ".concat(t.message))}}),500)),t.abrupt("return");case 3:if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),this._rpcWebSocketConnected){t.next=7;break}return this._rpcWebSocket.connect(),t.abrupt("return");case 7:return e=this._rpcWebSocketGeneration,n=function(){return e===r._rpcWebSocketGeneration},t.next=11,Promise.all(Object.keys(this._subscriptionsByHash).map(function(){var t=_(O().mark((function t(e){var i;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(i=r._subscriptionsByHash[e])){t.next=3;break}return t.abrupt("return");case 3:t.t0=i.state,t.next="pending"===t.t0||"unsubscribed"===t.t0?6:"subscribed"===t.t0?15:19;break;case 6:if(0!==i.callbacks.size){t.next=12;break}return delete r._subscriptionsByHash[e],"unsubscribed"===i.state&&delete r._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],t.next=11,r._updateSubscriptions();case 11:return t.abrupt("return");case 12:return t.next=14,_(O().mark((function t(){var o,a,s;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=i.args,a=i.method,t.prev=1,r._setSubscription(e,D(D({},i),{},{state:"subscribing"})),t.next=5,r._rpcWebSocket.call(a,o);case 5:return s=t.sent,r._setSubscription(e,D(D({},i),{},{serverSubscriptionId:s,state:"subscribed"})),r._subscriptionCallbacksByServerSubscriptionId[s]=i.callbacks,t.next=10,r._updateSubscriptions();case 10:t.next=20;break;case 12:if(t.prev=12,t.t0=t.catch(1),t.t0 instanceof Error&&console.error("".concat(a," error for argument"),o,t.t0.message),n()){t.next=17;break}return t.abrupt("return");case 17:return r._setSubscription(e,D(D({},i),{},{state:"pending"})),t.next=20,r._updateSubscriptions();case 20:case"end":return t.stop()}}),t,null,[[1,12]])})))();case 14:return t.abrupt("break",19);case 15:if(0!==i.callbacks.size){t.next=18;break}return t.next=18,_(O().mark((function t(){var o,a;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=i.serverSubscriptionId,a=i.unsubscribeMethod,!r._subscriptionsAutoDisposedByRpc.has(o)){t.next=5;break}r._subscriptionsAutoDisposedByRpc.delete(o),t.next=21;break;case 5:return r._setSubscription(e,D(D({},i),{},{state:"unsubscribing"})),r._setSubscription(e,D(D({},i),{},{state:"unsubscribing"})),t.prev=7,t.next=10,r._rpcWebSocket.call(a,[o]);case 10:t.next=21;break;case 12:if(t.prev=12,t.t0=t.catch(7),t.t0 instanceof Error&&console.error("".concat(a," error:"),t.t0.message),n()){t.next=17;break}return t.abrupt("return");case 17:return r._setSubscription(e,D(D({},i),{},{state:"subscribed"})),t.next=20,r._updateSubscriptions();case 20:return t.abrupt("return");case 21:return r._setSubscription(e,D(D({},i),{},{state:"unsubscribed"})),t.next=24,r._updateSubscriptions();case 24:case"end":return t.stop()}}),t,null,[[7,12]])})))();case 18:return t.abrupt("break",19);case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 11:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"_handleServerNotification",value:function(t,e){var n=this._subscriptionCallbacksByServerSubscriptionId[t];void 0!==n&&n.forEach((function(t){try{t.apply(void 0,et(e))}catch(t){console.error(t)}}))}},{key:"_wsOnAccountNotification",value:function(t){var e=co(t,Kc),n=e.result,r=e.subscription;this._handleServerNotification(r,[n.value,n.context])}},{key:"_makeSubscription",value:function(t,e){var n=this,r=this._nextClientSubscriptionId++,i=Xu([t.method,e],!0),o=this._subscriptionsByHash[i];return void 0===o?this._subscriptionsByHash[i]=D(D({},t),{},{args:e,callbacks:new Set([t.callback]),state:"pending"}):o.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=_(O().mark((function e(){var o;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return delete n._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete n._subscriptionHashByClientSubscriptionId[r],lu(void 0!==(o=n._subscriptionsByHash[i]),"Could not find a `Subscription` when tearing down client subscription #".concat(r)),o.callbacks.delete(t.callback),e.next=7,n._updateSubscriptions();case 7:case"end":return e.stop()}}),e)}))),this._updateSubscriptions(),r}},{key:"onAccountChange",value:function(t,e,n){var r=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},r)}},{key:"removeAccountChangeListener",value:(u=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"account change");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"_wsOnProgramAccountNotification",value:function(t){var e=co(t,tl),n=e.result,r=e.subscription;this._handleServerNotification(r,[{accountId:n.value.pubkey,accountInfo:n.value.account},n.context])}},{key:"onProgramAccountChange",value:function(t,e,n,r){var i=this._buildArgs([t.toBase58()],n||this._commitment||"finalized","base64",r?{filters:r}:void 0);return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},i)}},{key:"removeProgramAccountChangeListener",value:(s=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"program account change");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"onLogs",value:function(t,e,n){var r=this._buildArgs(["object"===z(t)?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},r)}},{key:"removeOnLogsListener",value:(a=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"logs");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"_wsOnLogsNotification",value:function(t){var e=co(t,Hl),n=e.result,r=e.subscription;this._handleServerNotification(r,[n.value,n.context])}},{key:"_wsOnSlotNotification",value:function(t){var e=co(t,nl),n=e.result,r=e.subscription;this._handleServerNotification(r,[n])}},{key:"onSlotChange",value:function(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}},{key:"removeSlotChangeListener",value:(o=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"slot change");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"_wsOnSlotUpdatesNotification",value:function(t){var e=co(t,il),n=e.result,r=e.subscription;this._handleServerNotification(r,[n])}},{key:"onSlotUpdate",value:function(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}},{key:"removeSlotUpdateListener",value:(i=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"slot update");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"_unsubscribeClientSubscription",value:(r=_(O().mark((function t(e,n){var r;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e])){t.next=6;break}return t.next=4,r();case 4:t.next=7;break;case 6:console.warn("Ignored unsubscribe request because an active subscription with id "+"`".concat(e,"` for '").concat(n,"' events ")+"could not be found.");case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"_buildArgs",value:function(t,e,n,r){var i=e||this._commitment;if(i||n||r){var o={};n&&(o.encoding=n),i&&(o.commitment=i),r&&(o=Object.assign(o,r)),t.push(o)}return t}},{key:"_buildArgsAtLeastConfirmed",value:function(t,e,n,r){var i=e||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,r)}},{key:"_wsOnSignatureNotification",value:function(t){var e=co(t,ol),n=e.result,r=e.subscription;"receivedSignature"!==n.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===n.value?[{type:"received"},n.context]:[{type:"status",result:n.value},n.context])}},{key:"onSignature",value:function(t,e,n){var r=this,i=this._buildArgs([t],n||this._commitment||"finalized"),o=this._makeSubscription({callback:function(t,n){if("status"===t.type){e(t.result,n);try{r.removeSignatureListener(o)}catch(t){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return o}},{key:"onSignatureWithOptions",value:function(t,e,n){var r=this,i=D(D({},n),{},{commitment:n&&n.commitment||this._commitment||"finalized"}),o=i.commitment,a=q(i,Bs),s=this._buildArgs([t],o,void 0,a),u=this._makeSubscription({callback:function(t,n){e(t,n);try{r.removeSignatureListener(u)}catch(t){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return u}},{key:"removeSignatureListener",value:(n=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"signature result");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"_wsOnRootNotification",value:function(t){var e=co(t,al),n=e.result,r=e.subscription;this._handleServerNotification(r,[n])}},{key:"onRootChange",value:function(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}},{key:"removeRootChangeListener",value:(e=_(O().mark((function t(e){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._unsubscribeClientSubscription(e,"root change");case 2:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]),t}(),Zl=function(){function t(e){B(this,t),this._keypair=void 0,this._keypair=null!=e?e:Us()}return U(t,[{key:"publicKey",get:function(){return new Xs(this._keypair.publicKey)}},{key:"secretKey",get:function(){return new Uint8Array(this._keypair.secretKey)}}],[{key:"generate",value:function(){return new t(Us())}},{key:"fromSecretKey",value:function(e,n){if(64!==e.byteLength)throw new Error("bad secret key size");var r=e.slice(32,64);if(!n||!n.skipValidation)for(var i=e.slice(0,32),o=Qs(i),a=0;a<32;a++)if(r[a]!==o[a])throw new Error("provided secretKey is invalid");return new t({publicKey:r,secretKey:e})}},{key:"fromSeed",value:function(e){var n=Qs(e),r=new Uint8Array(64);return r.set(e),r.set(n,32),new t({publicKey:n,secretKey:r})}}]),t}(),Jl=Object.freeze({CreateLookupTable:{index:0,layout:Fi([Qi("instruction"),Uu("recentSlot"),Ri("bumpSeed")])},FreezeLookupTable:{index:1,layout:Fi([Qi("instruction")])},ExtendLookupTable:{index:2,layout:Fi([Qi("instruction"),Uu(),Vi(iu(),Bi(Qi(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Fi([Qi("instruction")])},CloseLookupTable:{index:4,layout:Fi([Qi("instruction")])}}),Xl=function(){function t(){B(this,t)}return U(t,null,[{key:"decodeInstructionType",value:function(t){this.checkProgramId(t.programId);for(var e,n=Qi("instruction").decode(t.data),r=0,i=Object.entries(Jl);r2?t.keys[2].pubkey:void 0,addresses:e.map((function(t){return new Xs(t)}))}}},{key:"decodeCloseLookupTable",value:function(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}},{key:"decodeFreezeLookupTable",value:function(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}},{key:"decodeDeactivateLookupTable",value:function(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}},{key:"checkProgramId",value:function(t){if(!t.equals(Kl.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}},{key:"checkKeysLength",value:function(t,e){if(t.length3&&(i.custodianPubkey=t.keys[3].pubkey),i}},{key:"decodeAuthorizeWithSeed",value:function(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);var e=Ou(dh.AuthorizeWithSeed,t.data),n=e.newAuthorized,r=e.stakeAuthorizationType,i=e.authoritySeed,o=e.authorityOwner,a={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:i,authorityOwner:new Xs(o),newAuthorizedPubkey:new Xs(n),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(a.custodianPubkey=t.keys[3].pubkey),a}},{key:"decodeSplit",value:function(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);var e=Ou(dh.Split,t.data).lamports;return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}},{key:"decodeMerge",value:function(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ou(dh.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}},{key:"decodeWithdraw",value:function(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);var e=Ou(dh.Withdraw,t.data).lamports,n={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(n.custodianPubkey=t.keys[5].pubkey),n}},{key:"decodeDeactivate",value:function(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ou(dh.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}},{key:"checkProgramId",value:function(t){if(!t.equals(ph.programId))throw new Error("invalid instruction; programId is not StakeProgram")}},{key:"checkKeyLength",value:function(t,e){if(t.length0&&void 0!==arguments[0]?arguments[0]:"authorized";return Fi([iu("staker"),iu("withdrawer")],t)}(),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"lockup";return Fi([Wi("unixTimestamp"),Wi("epoch"),iu("custodian")],t)}()])},Authorize:{index:1,layout:Fi([Qi("instruction"),iu("newAuthorized"),Qi("stakeAuthorizationType")])},Delegate:{index:2,layout:Fi([Qi("instruction")])},Split:{index:3,layout:Fi([Qi("instruction"),Wi("lamports")])},Withdraw:{index:4,layout:Fi([Qi("instruction"),Wi("lamports")])},Deactivate:{index:5,layout:Fi([Qi("instruction")])},Merge:{index:7,layout:Fi([Qi("instruction")])},AuthorizeWithSeed:{index:8,layout:Fi([Qi("instruction"),iu("newAuthorized"),Qi("stakeAuthorizationType"),au("authoritySeed"),iu("authorityOwner")])}}),fh=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),ph=function(){function t(){B(this,t)}return U(t,null,[{key:"initialize",value:function(t){var e=t.stakePubkey,n=t.authorized,r=t.lockup||lh.default,i=Du(dh.Initialize,{authorized:{staker:Hs(n.staker.toBuffer()),withdrawer:Hs(n.withdrawer.toBuffer())},lockup:{unixTimestamp:r.unixTimestamp,epoch:r.epoch,custodian:Hs(r.custodian.toBuffer())}}),o={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Eu,isSigner:!1,isWritable:!1}],programId:this.programId,data:i};return new gu(o)}},{key:"createAccountWithSeed",value:function(t){var e=new vu;e.add(Wu.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));var n=t.stakePubkey,r=t.authorized,i=t.lockup;return e.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}},{key:"createAccount",value:function(t){var e=new vu;e.add(Wu.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));var n=t.stakePubkey,r=t.authorized,i=t.lockup;return e.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}},{key:"delegate",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=t.votePubkey,i=Du(dh.Delegate);return(new vu).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:Lu,isSigner:!1,isWritable:!1},{pubkey:uh,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}},{key:"authorize",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=t.newAuthorizedPubkey,i=t.stakeAuthorizationType,o=t.custodianPubkey,a=Du(dh.Authorize,{newAuthorized:Hs(r.toBuffer()),stakeAuthorizationType:i.index}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&s.push({pubkey:o,isSigner:!1,isWritable:!1}),(new vu).add({keys:s,programId:this.programId,data:a})}},{key:"authorizeWithSeed",value:function(t){var e=t.stakePubkey,n=t.authorityBase,r=t.authoritySeed,i=t.authorityOwner,o=t.newAuthorizedPubkey,a=t.stakeAuthorizationType,s=t.custodianPubkey,u=Du(dh.AuthorizeWithSeed,{newAuthorized:Hs(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:r,authorityOwner:Hs(i.toBuffer())}),c=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:Mu,isSigner:!1,isWritable:!1}];return s&&c.push({pubkey:s,isSigner:!1,isWritable:!1}),(new vu).add({keys:c,programId:this.programId,data:u})}},{key:"splitInstruction",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=t.splitStakePubkey,i=t.lamports,o=Du(dh.Split,{lamports:i});return new gu({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}},{key:"split",value:function(t){var e=new vu;return e.add(Wu.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),e.add(this.splitInstruction(t))}},{key:"splitWithSeed",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=t.splitStakePubkey,i=t.basePubkey,o=t.seed,a=t.lamports,s=new vu;return s.add(Wu.allocate({accountPubkey:r,basePubkey:i,seed:o,space:this.space,programId:this.programId})),s.add(this.splitInstruction({stakePubkey:e,authorizedPubkey:n,splitStakePubkey:r,lamports:a}))}},{key:"merge",value:function(t){var e=t.stakePubkey,n=t.sourceStakePubKey,r=t.authorizedPubkey,i=Du(dh.Merge);return(new vu).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:Lu,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}},{key:"withdraw",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=t.toPubkey,i=t.lamports,o=t.custodianPubkey,a=Du(dh.Withdraw,{lamports:i}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:Lu,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return o&&s.push({pubkey:o,isSigner:!1,isWritable:!1}),(new vu).add({keys:s,programId:this.programId,data:a})}},{key:"deactivate",value:function(t){var e=t.stakePubkey,n=t.authorizedPubkey,r=Du(dh.Deactivate);return(new vu).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}}]),t}();ph.programId=new Xs("Stake11111111111111111111111111111111111111"),ph.space=200;var yh=U((function t(e,n,r,i){B(this,t),this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=n,this.authorizedWithdrawer=r,this.commission=i})),mh=function(){function t(){B(this,t)}return U(t,null,[{key:"decodeInstructionType",value:function(t){this.checkProgramId(t.programId);for(var e,n=Qi("instruction").decode(t.data),r=0,i=Object.entries(gh);r0&&void 0!==arguments[0]?arguments[0]:"voteInit";return Fi([iu("nodePubkey"),iu("authorizedVoter"),iu("authorizedWithdrawer"),Ri("commission")],t)}()])},Authorize:{index:1,layout:Fi([Qi("instruction"),iu("newAuthorized"),Qi("voteAuthorizationType")])},Withdraw:{index:3,layout:Fi([Qi("instruction"),Wi("lamports")])},AuthorizeWithSeed:{index:10,layout:Fi([Qi("instruction"),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"voteAuthorizeWithSeedArgs";return Fi([Qi("voteAuthorizationType"),iu("currentAuthorityDerivedKeyOwnerPubkey"),au("currentAuthorityDerivedKeySeed"),iu("newAuthorized")],t)}()])}}),vh=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),wh=function(){function t(){B(this,t)}return U(t,null,[{key:"initializeAccount",value:function(t){var e=t.votePubkey,n=t.nodePubkey,r=t.voteInit,i=Du(gh.InitializeAccount,{voteInit:{nodePubkey:Hs(r.nodePubkey.toBuffer()),authorizedVoter:Hs(r.authorizedVoter.toBuffer()),authorizedWithdrawer:Hs(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Eu,isSigner:!1,isWritable:!1},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new gu(o)}},{key:"createAccount",value:function(t){var e=new vu;return e.add(Wu.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}},{key:"authorize",value:function(t){var e=t.votePubkey,n=t.authorizedPubkey,r=t.newAuthorizedPubkey,i=t.voteAuthorizationType,o=Du(gh.Authorize,{newAuthorized:Hs(r.toBuffer()),voteAuthorizationType:i.index}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new vu).add({keys:a,programId:this.programId,data:o})}},{key:"authorizeWithSeed",value:function(t){var e=t.currentAuthorityDerivedKeyBasePubkey,n=t.currentAuthorityDerivedKeyOwnerPubkey,r=t.currentAuthorityDerivedKeySeed,i=t.newAuthorizedPubkey,o=t.voteAuthorizationType,a=t.votePubkey,s=Du(gh.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Hs(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:Hs(i.toBuffer()),voteAuthorizationType:o.index}}),u=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:Mu,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return(new vu).add({keys:u,programId:this.programId,data:s})}},{key:"withdraw",value:function(t){var e=t.votePubkey,n=t.authorizedWithdrawerPubkey,r=t.lamports,i=t.toPubkey,o=Du(gh.Withdraw,{lamports:r}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return(new vu).add({keys:a,programId:this.programId,data:o})}},{key:"safeWithdraw",value:function(e,n,r){if(e.lamports>n-r)throw new Error("Withdraw will leave vote account with insuffcient funds.");return t.withdraw(e)}}]),t}();wh.programId=new Xs("Vote111111111111111111111111111111111111111"),wh.space=3731;var bh=new Xs("Va1idator1nfo111111111111111111111111111111"),Mh=Io({name:Ao(),website:bo(Ao()),details:bo(Ao()),keybaseUsername:bo(Ao())}),Ah=function(){function t(e,n){B(this,t),this.key=void 0,this.info=void 0,this.key=e,this.info=n}return U(t,null,[{key:"fromConfigData",value:function(e){var n=et(e);if(2!==uu(n))return null;for(var r=[],i=0;i<2;i++){var o=new Xs(n.slice(0,32)),a=1===(n=n.slice(32)).slice(0,1)[0];n=n.slice(1),r.push({publicKey:o,isSigner:a})}if(r[0].publicKey.equals(bh)&&r[1].isSigner){var s=au().decode(It.from(n)),u=JSON.parse(s);return uo(u,Mh),new t(r[1].publicKey,u)}return null}}]),t}(),Nh=new Xs("Vote111111111111111111111111111111111111111"),Ih=Fi([iu("nodePubkey"),iu("authorizedWithdrawer"),Ri("commission"),Yi(),Vi(Fi([Yi("slot"),Qi("confirmationCount")]),Bi(Qi(),-8),"votes"),Ri("rootSlotValid"),Yi("rootSlot"),Yi(),Vi(Fi([Yi("epoch"),iu("authorizedVoter")]),Bi(Qi(),-8),"authorizedVoters"),Fi([Vi(Fi([iu("authorizedPubkey"),Yi("epochOfLastAuthorizedSwitch"),Yi("targetEpoch")]),32,"buf"),Yi("idx"),Ri("isEmpty")],"priorVoters"),Yi(),Vi(Fi([Yi("epoch"),Yi("credits"),Yi("prevCredits")]),Bi(Qi(),-8),"epochCredits"),Fi([Yi("slot"),Yi("timestamp")],"lastTimestamp")]),Eh=function(){function t(e){B(this,t),this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}return U(t,null,[{key:"fromAccountData",value:function(e){var n=Ih.decode(Hs(e),4),r=n.rootSlot;return n.rootSlotValid||(r=null),new t({nodePubkey:new Xs(n.nodePubkey),authorizedWithdrawer:new Xs(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:r,authorizedVoters:n.authorizedVoters.map(xh),priorVoters:Th(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}]),t}();function xh(t){var e=t.authorizedVoter;return{epoch:t.epoch,authorizedVoter:new Xs(e)}}function kh(t){var e=t.authorizedPubkey,n=t.epochOfLastAuthorizedSwitch,r=t.targetEpoch;return{authorizedPubkey:new Xs(e),epochOfLastAuthorizedSwitch:n,targetEpoch:r}}function Th(t){var e=t.buf,n=t.idx;return t.isEmpty?[]:[].concat(et(e.slice(n+1).map(kh)),et(e.slice(0,n).map(kh)))}var Lh={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Sh(){return(Sh=_(O().mark((function t(e,n,r,i){var o,a,s,u,c,l,h;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r&&Object.prototype.hasOwnProperty.call(r,"lastValidBlockHeight")||r&&Object.prototype.hasOwnProperty.call(r,"nonceValue")?(o=r,a=i):a=r,s=a&&{skipPreflight:a.skipPreflight,preflightCommitment:a.preflightCommitment||a.commitment,minContextSlot:a.minContextSlot},t.next=4,e.sendRawTransaction(n,s);case 4:return u=t.sent,c=a&&a.commitment,l=o?e.confirmTransaction(o,c):e.confirmTransaction(u,c),t.next=9,l;case 9:if(!(h=t.sent.value).err){t.next=12;break}throw new Error("Raw transaction ".concat(u," failed (").concat(JSON.stringify(h),")"));case 12:return t.abrupt("return",u);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var jh=j(Object.freeze({__proto__:null,Account:Ks,AddressLookupTableAccount:ic,AddressLookupTableInstruction:Xl,AddressLookupTableProgram:Kl,Authorized:ch,BLOCKHASH_CACHE_TIMEOUT_MS:3e4,BPF_LOADER_DEPRECATED_PROGRAM_ID:$s,BPF_LOADER_PROGRAM_ID:Vu,BpfLoader:Hu,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:th,ComputeBudgetInstruction:$l,ComputeBudgetProgram:eh,Connection:ql,Ed25519Program:rh,Enum:qs,EpochSchedule:$u,FeeCalculatorLayout:Pu,Keypair:Zl,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Jl,Loader:Fu,Lockup:lh,MAX_SEED_LENGTH:32,Message:du,MessageAccountKeys:ru,MessageV0:fu,NONCE_ACCOUNT_LENGTH:Bu,NonceAccount:Ru,PACKET_DATA_SIZE:1232,PUBLIC_KEY_LENGTH:32,PublicKey:Xs,SIGNATURE_LENGTH_IN_BYTES:64,SOLANA_SCHEMA:Zs,STAKE_CONFIG_ID:uh,STAKE_INSTRUCTION_LAYOUTS:dh,SYSTEM_INSTRUCTION_LAYOUTS:Yu,SYSVAR_CLOCK_PUBKEY:Mu,SYSVAR_EPOCH_SCHEDULE_PUBKEY:Au,SYSVAR_INSTRUCTIONS_PUBKEY:Nu,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Iu,SYSVAR_RENT_PUBKEY:Eu,SYSVAR_REWARDS_PUBKEY:xu,SYSVAR_SLOT_HASHES_PUBKEY:ku,SYSVAR_SLOT_HISTORY_PUBKEY:Tu,SYSVAR_STAKE_HISTORY_PUBKEY:Lu,Secp256k1Program:sh,SendTransactionError:tc,SolanaJSONRPCError:ec,SolanaJSONRPCErrorCode:{JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},StakeAuthorizationLayout:fh,StakeInstruction:hh,StakeProgram:ph,Struct:Gs,SystemInstruction:Qu,SystemProgram:Wu,Transaction:vu,TransactionExpiredBlockheightExceededError:tu,TransactionExpiredNonceInvalidError:nu,TransactionExpiredTimeoutError:eu,TransactionInstruction:gu,TransactionMessage:wu,TransactionStatus:yu,VALIDATOR_INFO_KEY:bh,VERSION_PREFIX_MASK:127,VOTE_PROGRAM_ID:Nh,ValidatorInfo:Ah,VersionedMessage:pu,VersionedTransaction:bu,VoteAccount:Eh,VoteAuthorizationLayout:vh,VoteInit:yh,VoteInstruction:mh,VoteProgram:wh,clusterApiUrl:function(t,e){var n=!1===e?"http":"https";if(!t)return Lh[n].devnet;var r=Lh[n][t];if(!r)throw new Error("Unknown ".concat(n," cluster: ").concat(t));return r},sendAndConfirmRawTransaction:function(t,e,n,r){return Sh.apply(this,arguments)},sendAndConfirmTransaction:Su})),Ch={};Object.defineProperty(Ch,"__esModule",{value:!0});var Dh={ERROR_ASSOCIATION_PORT_OUT_OF_RANGE:"ERROR_ASSOCIATION_PORT_OUT_OF_RANGE",ERROR_FORBIDDEN_WALLET_BASE_URL:"ERROR_FORBIDDEN_WALLET_BASE_URL",ERROR_SECURE_CONTEXT_REQUIRED:"ERROR_SECURE_CONTEXT_REQUIRED",ERROR_SESSION_CLOSED:"ERROR_SESSION_CLOSED",ERROR_SESSION_TIMEOUT:"ERROR_SESSION_TIMEOUT",ERROR_WALLET_NOT_FOUND:"ERROR_WALLET_NOT_FOUND"},Oh=function(t){Y(n,G(Error));var e=X(n);function n(){var t;B(this,n);for(var r=arguments.length,i=new Array(r),o=0;o=4294967296)throw new Error("Outbound sequence number overflow. The maximum sequence number is 32-bytes.");var e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t,!1),new Uint8Array(e)}function Rh(){return Ph(this,void 0,void 0,O().mark((function t(){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign"]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))}function Uh(){return Ph(this,void 0,void 0,O().mark((function t(){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!1,["deriveKey","deriveBits"]);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))}var Qh;function Yh(t,e){return Ph(this,void 0,void 0,O().mark((function n(){var r,i,o,a,s;return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=JSON.stringify(t),i=Bh(t.id),o=new Uint8Array(12),crypto.getRandomValues(o),n.next=6,crypto.subtle.encrypt(Fh(i,o),e,(new TextEncoder).encode(r));case 6:return a=n.sent,(s=new Uint8Array(i.byteLength+o.byteLength+a.byteLength)).set(new Uint8Array(i),0),s.set(new Uint8Array(o),i.byteLength),s.set(new Uint8Array(a),i.byteLength+o.byteLength),n.abrupt("return",s);case 12:case"end":return n.stop()}}),n)})))}function Wh(t,e){return Ph(this,void 0,void 0,O().mark((function n(){var r,i,o,a,s,u;return O().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=t.slice(0,4),i=t.slice(4,16),o=t.slice(16),n.next=5,crypto.subtle.decrypt(Fh(r,i),e,o);case 5:if(a=n.sent,s=Vh().decode(a),u=JSON.parse(s),!Object.hasOwnProperty.call(u,"error")){n.next=10;break}throw new zh(u.id,u.error.code,u.error.message);case 10:return n.abrupt("return",u);case 11:case"end":return n.stop()}}),n)})))}function Fh(t,e){return{additionalData:t,iv:e,name:"AES-GCM",tagLength:128}}function Vh(){return void 0===Qh&&(Qh=new TextDecoder("utf-8")),Qh}function Hh(t,e,n){return Ph(this,void 0,void 0,O().mark((function r(){var i,o,a,s,u,c,l;return O().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Promise.all([crypto.subtle.exportKey("raw",e),crypto.subtle.importKey("raw",t,{name:"ECDH",namedCurve:"P-256"},!1,[])]);case 2:return i=r.sent,o=tt(i,2),a=o[0],s=o[1],r.next=8,crypto.subtle.deriveBits({name:"ECDH",public:s},n,256);case 8:return u=r.sent,r.next=11,crypto.subtle.importKey("raw",u,"HKDF",!1,["deriveKey"]);case 11:return c=r.sent,r.next=14,crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-256",salt:new Uint8Array(a),info:new Uint8Array},c,{name:"AES-GCM",length:128},!1,["encrypt","decrypt"]);case 14:return l=r.sent,r.abrupt("return",l);case 16:case"end":return r.stop()}}),r)})))}function Gh(t){if(t<49152||t>65535)throw new Oh(Dh.ERROR_ASSOCIATION_PORT_OUT_OF_RANGE,"Association port number must be between 49152 and 65535. ".concat(t," given."),{port:t});return t}function qh(t){for(var e="",n=new Uint8Array(t),r=n.byteLength,i=0;i1?t.shift():t[0]}}(),u=1,c=0,l={__type:"disconnected"},n.abrupt("return",new Promise((function(e,n){var d,f,p,y={},m=function t(){return Ph(h,void 0,void 0,O().mark((function e(){var n,r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("connecting"===l.__type){e.next=3;break}return console.warn("Expected adapter state to be `connecting` at the moment the websocket opens. "+"Got `".concat(l.__type,"`.")),e.abrupt("return");case 3:return n=l.associationKeypair,d.removeEventListener("open",t),e.next=7,Uh();case 7:return r=e.sent,e.t0=d,e.next=11,_h(r.publicKey,n.privateKey);case 11:e.t1=e.sent,e.t0.send.call(e.t0,e.t1),l={__type:"hello_req_sent",associationPublicKey:n.publicKey,ecdhPrivateKey:r.privateKey};case 14:case"end":return e.stop()}}),e)})))},g=function(t){t.wasClean?l={__type:"disconnected"}:n(new Oh(Dh.ERROR_SESSION_CLOSED,"The wallet session dropped unexpectedly (".concat(t.code,": ").concat(t.reason,")."),{closeEvent:t})),f()},v=function(t){return Ph(h,void 0,void 0,O().mark((function t(){return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(f(),!(Date.now()-a>=rd)){t.next=5;break}n(new Oh(Dh.ERROR_SESSION_TIMEOUT,"Failed to connect to the wallet websocket on port ".concat(i,"."))),t.next=8;break;case 5:return t.next=7,new Promise((function(t){var e=s();p=window.setTimeout(t,e)}));case 7:b();case 8:case"end":return t.stop()}}),t)})))},w=function(r){return Ph(h,void 0,void 0,O().mark((function i(){var o,a,s,h,p,m,g,v;return O().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,r.data.arrayBuffer();case 2:o=i.sent,i.t0=l.__type,i.next="connected"===i.t0?6:"hello_req_sent"===i.t0?30:51;break;case 6:if(i.prev=6,a=o.slice(0,4),(s=new DataView(a).getUint32(0,!1))===c+1){i.next=11;break}throw new Error("Encrypted message has invalid sequence number");case 11:return c=s,i.next=14,Wh(o,l.sharedSecret);case 14:h=i.sent,p=y[h.id],delete y[h.id],p.resolve(h.result),i.next=29;break;case 20:if(i.prev=20,i.t1=i.catch(6),!(i.t1 instanceof zh)){i.next=28;break}m=y[i.t1.jsonRpcMessageId],delete y[i.t1.jsonRpcMessageId],m.reject(i.t1),i.next=29;break;case 28:throw i.t1;case 29:return i.abrupt("break",51);case 30:return i.next=32,Hh(o,l.associationPublicKey,l.ecdhPrivateKey);case 32:return g=i.sent,l={__type:"connected",sharedSecret:g},v=new Proxy({},{get:function(t,e){if(null==t[e]){var n=e.toString().replace(/[A-Z]/g,(function(t){return"_".concat(t.toLowerCase())})).toLowerCase();t[e]=function(t){return Ph(this,void 0,void 0,O().mark((function r(){var i;return O().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=u++,r.t0=d,r.next=4,Yh({id:i,jsonrpc:"2.0",method:n,params:null!=t?t:{}},g);case 4:return r.t1=r.sent,r.t0.send.call(r.t0,r.t1),r.abrupt("return",new Promise((function(t,n){y[i]={resolve:function(r){switch(e){case"authorize":case"reauthorize":var i=r.wallet_uri_base;if(null!=i)try{od(i)}catch(t){return void n(t)}}t(r)},reject:n}})));case 7:case"end":return r.stop()}}),r)})))}}return t[e]},defineProperty:function(){return!1},deleteProperty:function(){return!1}}),i.prev=35,i.t2=e,i.next=39,t(v);case 39:i.t3=i.sent,(0,i.t2)(i.t3),i.next=46;break;case 43:i.prev=43,i.t4=i.catch(35),n(i.t4);case 46:return i.prev=46,f(),d.close(),i.finish(46);case 50:return i.abrupt("break",51);case 51:case"end":return i.stop()}}),i,null,[[6,20],[35,43,46,50]])})))},b=function(){f&&f(),l={__type:"connecting",associationKeypair:r},void 0===a&&(a=Date.now()),(d=new WebSocket(o,["com.solana.mobilewalletadapter.v1"])).addEventListener("open",m),d.addEventListener("close",g),d.addEventListener("error",v),d.addEventListener("message",w),f=function(){window.clearTimeout(p),d.removeEventListener("open",m),d.removeEventListener("close",g),d.removeEventListener("error",v),d.removeEventListener("message",w)}};b()})));case 13:case"end":return n.stop()}}),n)})))};var ad=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n>>0,c=new Uint8Array(o);t[n];){var l=e[t.charCodeAt(n)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,n++}for(var f=o-i;f!==o&&0===c[f];)f++;for(var p=new Uint8Array(r+(o-f)),y=r;f!==o;)p[y++]=c[f++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var u=(o-i)*c+1>>>0,l=new Uint8Array(u);i!==o;){for(var h=e[i],d=0,f=u-1;(0!==h||d>>0,l[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");r=d,i++}for(var p=u-r;p!==u&&0===l[p];)p++;for(var y=s.repeat(n);pthis.span)throw new RangeError("indeterminate span");return this.span}},{key:"replicate",value:function(t){var e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}},{key:"fromArray",value:function(t){}}]),t}();function wd(t,e){return e.property?t+"["+e.property+"]":t}gd.Layout=vd,gd.nameWithProperty=wd,gd.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(t.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof vd))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=function(){return new t},Object.defineProperty(t.prototype,"encode",{value:function(t,n){return e.encode(this,t,n)},writable:!0}),Object.defineProperty(t,"decode",{value:function(t,n){return e.decode(t,n)},writable:!0})};var bd=function(t){Y(n,vd);var e=X(n);function n(){return B(this,n),e.apply(this,arguments)}return U(n,[{key:"isCount",value:function(){throw new Error("ExternalLayout is abstract")}}]),n}(),Md=function(t){Y(n,bd);var e=X(n);function n(t,r){var i;if(B(this,n),void 0===t&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");return(i=e.call(this,-1,r)).elementSpan=t,i}return U(n,[{key:"isCount",value:function(){return!0}},{key:"decode",value:function(t,e){void 0===e&&(e=0);var n=t.length-e;return Math.floor(n/this.elementSpan)}},{key:"encode",value:function(t,e,n){return 0}}]),n}(),Ad=function(t){Y(n,bd);var e=X(n);function n(t,r,i){var o;if(B(this,n),!(t instanceof vd))throw new TypeError("layout must be a Layout");if(void 0===r)r=0;else if(!Number.isInteger(r))throw new TypeError("offset must be integer or undefined");return(o=e.call(this,t.span,i||t.property)).layout=t,o.offset=r,o}return U(n,[{key:"isCount",value:function(){return this.layout instanceof Nd||this.layout instanceof Id}},{key:"decode",value:function(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),this.layout.encode(t,e,n+this.offset)}}]),n}(),Nd=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;if(B(this,n),6<(i=e.call(this,t,r)).span)throw new RangeError("span must not exceed 6 bytes");return i}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeUIntLE(t,n,this.span),this.span}}]),n}(),Id=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;if(B(this,n),6<(i=e.call(this,t,r)).span)throw new RangeError("span must not exceed 6 bytes");return i}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeUIntBE(t,n,this.span),this.span}}]),n}(),Ed=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;if(B(this,n),6<(i=e.call(this,t,r)).span)throw new RangeError("span must not exceed 6 bytes");return i}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readIntLE(e,this.span)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeIntLE(t,n,this.span),this.span}}]),n}(),xd=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;if(B(this,n),6<(i=e.call(this,t,r)).span)throw new RangeError("span must not exceed 6 bytes");return i}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readIntBE(e,this.span)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeIntBE(t,n,this.span),this.span}}]),n}(),kd=Math.pow(2,32);function Td(t){var e=Math.floor(t/kd);return{hi32:e,lo32:t-e*kd}}function Ld(t,e){return t*kd+e}var Sd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){void 0===e&&(e=0);var n=t.readUInt32LE(e);return Ld(t.readUInt32LE(e+4),n)}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=Td(t);return e.writeUInt32LE(r.lo32,n),e.writeUInt32LE(r.hi32,n+4),8}}]),n}(),jd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),Ld(t.readUInt32BE(e),t.readUInt32BE(e+4))}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=Td(t);return e.writeUInt32BE(r.hi32,n),e.writeUInt32BE(r.lo32,n+4),8}}]),n}(),Cd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){void 0===e&&(e=0);var n=t.readUInt32LE(e);return Ld(t.readInt32LE(e+4),n)}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=Td(t);return e.writeUInt32LE(r.lo32,n),e.writeInt32LE(r.hi32,n+4),8}}]),n}(),Dd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),Ld(t.readInt32BE(e),t.readUInt32BE(e+4))}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=Td(t);return e.writeInt32BE(r.hi32,n),e.writeUInt32BE(r.lo32,n+4),8}}]),n}(),Od=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,4,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readFloatLE(e)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeFloatLE(t,n),4}}]),n}(),zd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,4,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readFloatBE(e)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeFloatBE(t,n),4}}]),n}(),Pd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readDoubleLE(e)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeDoubleLE(t,n),8}}]),n}(),_d=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,8,t)}return U(n,[{key:"decode",value:function(t,e){return void 0===e&&(e=0),t.readDoubleBE(e)}},{key:"encode",value:function(t,e,n){return void 0===n&&(n=0),e.writeDoubleBE(t,n),8}}]),n}(),Bd=function(t){Y(n,vd);var e=X(n);function n(t,r,i){var o;if(B(this,n),!(t instanceof vd))throw new TypeError("elementLayout must be a Layout");if(!(r instanceof bd&&r.isCount()||Number.isInteger(r)&&0<=r))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");var a=-1;return!(r instanceof bd)&&0u.span&&void 0===u.property)throw new Error("fields cannot contain unnamed variable-length layout")}}catch(t){s.e(t)}finally{s.f()}var c=-1;try{c=t.reduce((function(t,e){return t+e.getSpan()}),0)}catch(t){}return(o=e.call(this,c,r)).fields=t,o.decodePrefixes=!!i,o}return U(n,[{key:"getSpan",value:function(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);var n=0;try{n=this.fields.reduce((function(n,r){var i=r.getSpan(t,e);return e+=i,n+i}),0)}catch(t){throw new RangeError("indeterminate span")}return n}},{key:"decode",value:function(t,e){void 0===e&&(e=0);var n,r=this.makeDestinationObject(),i=st(this.fields);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(void 0!==o.property&&(r[o.property]=o.decode(t,e)),e+=o.getSpan(t,e),this.decodePrefixes&&t.length===e)break}}catch(t){i.e(t)}finally{i.f()}return r}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r,i=n,o=0,a=0,s=st(this.fields);try{for(s.s();!(r=s.n()).done;){var u=r.value,c=u.span;if(a=0c&&(c=u.getSpan(e,n)))}o=n,n+=c}}catch(t){s.e(t)}finally{s.f()}return o+a-i}},{key:"fromArray",value:function(t){var e,n=this.makeDestinationObject(),r=st(this.fields);try{for(r.s();!(e=r.n()).done;){var i=e.value;void 0!==i.property&&0i.span?n=-1:0<=n&&(n+=i.span)}}catch(t){r.e(t)}finally{r.f()}}}]),n}(),Ud=function(){function t(e){B(this,t),this.property=e}return U(t,[{key:"decode",value:function(){throw new Error("UnionDiscriminator is abstract")}},{key:"encode",value:function(){throw new Error("UnionDiscriminator is abstract")}}]),t}(),Qd=function(t){Y(n,Ud);var e=X(n);function n(t,r){var i;if(B(this,n),!(t instanceof bd&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");return(i=e.call(this,r||t.property||"variant")).layout=t,i}return U(n,[{key:"decode",value:function(t,e){return this.layout.decode(t,e)}},{key:"encode",value:function(t,e,n){return this.layout.encode(t,e,n)}}]),n}(),Yd=function(t){Y(n,vd);var e=X(n);function n(t,r,i){var o;B(this,n);var a=t instanceof Nd||t instanceof Id;if(a)t=new Qd(new Ad(t));else if(t instanceof bd&&t.isCount())t=new Qd(t);else if(!(t instanceof Ud))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===r&&(r=null),!(null===r||r instanceof vd))throw new TypeError("defaultLayout must be null or a Layout");if(null!==r){if(0>r.span)throw new Error("defaultLayout must have constant span");void 0===r.property&&(r=r.replicate("content"))}var s=-1;r&&0<=(s=r.span)&&a&&(s+=t.layout.span),(o=e.call(this,s,i)).discriminator=t,o.usesPrefixDiscriminator=a,o.defaultLayout=r,o.registry={};var u=o.defaultGetSourceVariant.bind(Z(o));return o.getSourceVariant=function(t){return u(t)},o.configGetSourceVariant=function(t){u=t.bind(this)},o}return U(n,[{key:"getSpan",value:function(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);var n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}},{key:"defaultGetSourceVariant",value:function(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;var e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(var n in this.registry){var r=this.registry[n];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}},{key:"decode",value:function(t,e){var n;void 0===e&&(e=0);var r=this.discriminator,i=r.decode(t,e),o=this.registry[i];if(void 0===o){var a=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(a=r.layout.span),(n=this.makeDestinationObject())[r.property]=i,n[o.property]=this.defaultLayout.decode(t,e+a)}else n=o.decode(t,e);return n}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=this.getSourceVariant(t);if(void 0===r){var i=this.discriminator,o=this.defaultLayout,a=0;return this.usesPrefixDiscriminator&&(a=i.layout.span),i.encode(t[i.property],e,n),a+o.encode(t[o.property],e,n+a)}return r.encode(t,e,n)}},{key:"addVariant",value:function(t,e,n){var r=new Wd(this,t,e,n);return this.registry[t]=r,r}},{key:"getVariant",value:function(t,e){var n=t;return It.isBuffer(t)&&(void 0===e&&(e=0),n=this.discriminator.decode(t,e)),this.registry[n]}}]),n}(),Wd=function(t){Y(n,vd);var e=X(n);function n(t,r,i,o){var a;if(B(this,n),!(t instanceof Yd))throw new TypeError("union must be a Union");if(!Number.isInteger(r)||0>r)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof i&&void 0===o&&(o=i,i=null),i){if(!(i instanceof vd))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=i.span&&i.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof o)throw new TypeError("variant must have a String property")}var s=t.span;return 0>t.span&&0<=(s=i?i.span:0)&&t.usesPrefixDiscriminator&&(s+=t.discriminator.layout.span),(a=e.call(this,s,o)).union=t,a.variant=r,a.layout=i||null,a}return U(n,[{key:"getSpan",value:function(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);var n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),n+this.layout.getSpan(t,e+n)}},{key:"decode",value:function(t,e){var n=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");var r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}},{key:"encode",value:function(t,e,n){void 0===n&&(n=0);var r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);var i=r;if(this.layout&&(this.layout.encode(t[this.property],e,n+r),i+=this.layout.getSpan(e,n+r),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}},{key:"fromArray",value:function(t){if(this.layout)return this.layout.fromArray(t)}}]),n}();function Fd(t){return 0>t&&(t+=4294967296),t}var Vd=function(t){Y(n,vd);var e=X(n);function n(t,r,i){var o;if(B(this,n),!(t instanceof Nd||t instanceof Id))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof r&&void 0===i&&(i=r,r=void 0),4=n)throw new TypeError("bits must be positive integer");var i=8*e.span,o=e.fields.reduce((function(t,e){return t+e.bits}),0);if(n+o>i)throw new Error("bits too long for span remainder ("+(i-o)+" of "+i+" remain)");this.container=e,this.bits=n,this.valueMask=(1<>>this.start}},{key:"encode",value:function(t){if(!Number.isInteger(t)||t!==Fd(t&this.valueMask))throw new TypeError(wd("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);var e=this.container._packedGetValue(),n=Fd(t<n&&(n=this.length.decode(t,e)),n}},{key:"decode",value:function(t,e){void 0===e&&(e=0);var n=this.span;return 0>n&&(n=this.length.decode(t,e)),t.slice(e,e+n)}},{key:"encode",value:function(t,e,n){var r=this.length;if(this.length instanceof bd&&(r=t.length),!It.isBuffer(t)||r!==t.length)throw new TypeError(wd("Blob.encode",this)+" requires (length "+r+") Buffer as src");if(n+r>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),n,r,"hex"),this.length instanceof bd&&this.length.encode(r,e,n),r}}]),n}(),Zd=function(t){Y(n,vd);var e=X(n);function n(t){return B(this,n),e.call(this,-1,t)}return U(n,[{key:"getSpan",value:function(t,e){if(!It.isBuffer(t))throw new TypeError("b must be a Buffer");void 0===e&&(e=0);for(var n=e;ne.length)throw new RangeError("encoding overruns Buffer");return r.copy(e,n),e[n+i]=0,i+1}}]),n}(),Jd=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;if(B(this,n),"string"==typeof t&&void 0===r&&(r=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");return(i=e.call(this,-1,r)).maxSpan=t,i}return U(n,[{key:"getSpan",value:function(t,e){if(!It.isBuffer(t))throw new TypeError("b must be a Buffer");return void 0===e&&(e=0),t.length-e}},{key:"decode",value:function(t,e,n){void 0===e&&(e=0);var r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpane.length)throw new RangeError("encoding overruns Buffer");return r.copy(e,n),i}}]),n}(),Xd=function(t){Y(n,vd);var e=X(n);function n(t,r){var i;return B(this,n),(i=e.call(this,0,r)).value=t,i}return U(n,[{key:"decode",value:function(t,e,n){return this.value}},{key:"encode",value:function(t,e,n){return 0}}]),n}();gd.ExternalLayout=bd,gd.GreedyCount=Md,gd.OffsetLayout=Ad,gd.UInt=Nd,gd.UIntBE=Id,gd.Int=Ed,gd.IntBE=xd,gd.Float=Od,gd.FloatBE=zd,gd.Double=Pd,gd.DoubleBE=_d,gd.Sequence=Bd,gd.Structure=Rd,gd.UnionDiscriminator=Ud,gd.UnionLayoutDiscriminator=Qd,gd.Union=Yd,gd.VariantLayout=Wd,gd.BitStructure=Vd,gd.BitField=Hd,gd.Boolean=Gd,gd.Blob=qd,gd.CString=Zd,gd.UTF8=Jd,gd.Constant=Xd,gd.greedy=function(t,e){return new Md(t,e)},gd.offset=function(t,e,n){return new Ad(t,e,n)},gd.u8=function(t){return new Nd(1,t)},gd.u16=function(t){return new Nd(2,t)},gd.u24=function(t){return new Nd(3,t)},gd.u32=function(t){return new Nd(4,t)},gd.u40=function(t){return new Nd(5,t)},gd.u48=function(t){return new Nd(6,t)},gd.nu64=function(t){return new Sd(t)},gd.u16be=function(t){return new Id(2,t)},gd.u24be=function(t){return new Id(3,t)},gd.u32be=function(t){return new Id(4,t)},gd.u40be=function(t){return new Id(5,t)},gd.u48be=function(t){return new Id(6,t)},gd.nu64be=function(t){return new jd(t)},gd.s8=function(t){return new Ed(1,t)},gd.s16=function(t){return new Ed(2,t)},gd.s24=function(t){return new Ed(3,t)},gd.s32=function(t){return new Ed(4,t)},gd.s40=function(t){return new Ed(5,t)},gd.s48=function(t){return new Ed(6,t)},gd.ns64=function(t){return new Cd(t)},gd.s16be=function(t){return new xd(2,t)},gd.s24be=function(t){return new xd(3,t)},gd.s32be=function(t){return new xd(4,t)},gd.s40be=function(t){return new xd(5,t)},gd.s48be=function(t){return new xd(6,t)},gd.ns64be=function(t){return new Dd(t)},gd.f32=function(t){return new Od(t)},gd.f32be=function(t){return new zd(t)},gd.f64=function(t){return new Pd(t)},gd.f64be=function(t){return new _d(t)},gd.struct=function(t,e,n){return new Rd(t,e,n)},gd.bits=function(t,e,n){return new Vd(t,e,n)};var Kd=gd.seq=function(t,e,n){return new Bd(t,e,n)};gd.union=function(t,e,n){return new Yd(t,e,n)},gd.unionLayoutDiscriminator=function(t,e){return new Qd(t,e)},gd.blob=function(t,e){return new qd(t,e)},gd.cstr=function(t){return new Zd(t)},gd.utf8=function(t,e){return new Jd(t,e)},gd.const=function(t,e){return new Xd(t,e)};var $d={},tf={exports:{}};!function(t,e){function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function r(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}function i(t,e,n){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(n=e,e=10),this._init(t||0,e||10,n||"be"))}var o;"object"===z(t)?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ur.Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function s(t,e,n){var r=a(t,n);return n-1>=e&&(r|=a(t,n-1)<<4),r}function u(t,e,r,i){for(var o=0,a=0,s=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&a0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"===z(t))return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,n){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=2)i=s(t,e,r)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(r=(t.length-e)%2==0?e+1:e;r=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,n){this.words=[0],this.length=1;for(var r=0,i=1;i<=67108863;i*=e)r++;r--,i=i/e|0;for(var o=t.length-n,a=o%r,s=Math.min(o,o-a)+n,c=0,l=n;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?""}var h=["","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];function p(t,e,n){n.negative=e.negative^t.negative;var r=t.length+e.length|0;n.length=r,r=r-1|0;var i=0|t.words[0],o=0|e.words[0],a=i*o,s=67108863&a,u=a/67108864|0;n.words[0]=s;for(var c=1;c>>26,h=67108863&u,d=Math.min(c,e.length-1),f=Math.max(0,c-t.length+1);f<=d;f++){var p=c-f|0;l+=(a=(i=0|t.words[p])*(o=0|e.words[f])+h)/67108864|0,h=67108863&a}n.words[c]=0|h,u=0|l}return 0!==u?n.words[c]=0|u:n.length--,n._strip()}i.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,a=0;a>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?h[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var c=d[t],l=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(l).toString(t);r=(p=p.idivn(l)).isZero()?y+r:h[c-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},i.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&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(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,i),a},i.prototype._toArrayLikeLE=function(t,e){for(var n=0,r=0,i=0,o=0;i>8&255),n>16&255),6===o?(n>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n=0&&(t[n--]=a>>8&255),n>=0&&(t[n--]=a>>16&255),6===o?(n>=0&&(t[n--]=a>>24&255),r=0,o=0):(r=a>>>24,o+=2)}if(n>=0)for(t[n--]=r;n>=0;)t[n--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,n=0;return e>=4096&&(n+=13,e>>>=13),e>=64&&(n+=7,e>>>=7),e>=8&&(n+=4,e>>>=4),e>=2&&(n+=2,e>>>=2),n+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,n=0;return 0==(8191&e)&&(n+=13,e>>>=13),0==(127&e)&&(n+=7,e>>>=7),0==(15&e)&&(n+=4,e>>>=4),0==(3&e)&&(n+=2,e>>>=2),0==(1&e)&&n++,n},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var n=0;nt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,n;this.length>t.length?(e=this,n=t):(e=t,n=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<t.length?(n=this,r=t):(n=t,r=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},i.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 n,r,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,r=t):(n=t,r=this);for(var o=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==o&&a>26,this.words[a]=67108863&e;if(0===o&&a>>13,f=0|a[1],p=8191&f,y=f>>>13,m=0|a[2],g=8191&m,v=m>>>13,w=0|a[3],b=8191&w,M=w>>>13,A=0|a[4],N=8191&A,I=A>>>13,E=0|a[5],x=8191&E,k=E>>>13,T=0|a[6],L=8191&T,S=T>>>13,j=0|a[7],C=8191&j,D=j>>>13,O=0|a[8],z=8191&O,P=O>>>13,_=0|a[9],B=8191&_,R=_>>>13,U=0|s[0],Q=8191&U,Y=U>>>13,W=0|s[1],F=8191&W,V=W>>>13,H=0|s[2],G=8191&H,q=H>>>13,Z=0|s[3],J=8191&Z,X=Z>>>13,K=0|s[4],$=8191&K,tt=K>>>13,et=0|s[5],nt=8191&et,rt=et>>>13,it=0|s[6],ot=8191&it,at=it>>>13,st=0|s[7],ut=8191&st,ct=st>>>13,lt=0|s[8],ht=8191<,dt=lt>>>13,ft=0|s[9],pt=8191&ft,yt=ft>>>13;n.negative=t.negative^e.negative,n.length=19;var mt=(c+(r=Math.imul(h,Q))|0)+((8191&(i=(i=Math.imul(h,Y))+Math.imul(d,Q)|0))<<13)|0;c=((o=Math.imul(d,Y))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,r=Math.imul(p,Q),i=(i=Math.imul(p,Y))+Math.imul(y,Q)|0,o=Math.imul(y,Y);var gt=(c+(r=r+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,V)|0)+Math.imul(d,F)|0))<<13)|0;c=((o=o+Math.imul(d,V)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(g,Q),i=(i=Math.imul(g,Y))+Math.imul(v,Q)|0,o=Math.imul(v,Y),r=r+Math.imul(p,F)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(y,F)|0,o=o+Math.imul(y,V)|0;var vt=(c+(r=r+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,q)|0)+Math.imul(d,G)|0))<<13)|0;c=((o=o+Math.imul(d,q)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(b,Q),i=(i=Math.imul(b,Y))+Math.imul(M,Q)|0,o=Math.imul(M,Y),r=r+Math.imul(g,F)|0,i=(i=i+Math.imul(g,V)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,V)|0,r=r+Math.imul(p,G)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(y,G)|0,o=o+Math.imul(y,q)|0;var wt=(c+(r=r+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,J)|0))<<13)|0;c=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(N,Q),i=(i=Math.imul(N,Y))+Math.imul(I,Q)|0,o=Math.imul(I,Y),r=r+Math.imul(b,F)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,V)|0,r=r+Math.imul(g,G)|0,i=(i=i+Math.imul(g,q)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,q)|0,r=r+Math.imul(p,J)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,X)|0;var bt=(c+(r=r+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(d,$)|0))<<13)|0;c=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(x,Q),i=(i=Math.imul(x,Y))+Math.imul(k,Q)|0,o=Math.imul(k,Y),r=r+Math.imul(N,F)|0,i=(i=i+Math.imul(N,V)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,V)|0,r=r+Math.imul(b,G)|0,i=(i=i+Math.imul(b,q)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,q)|0,r=r+Math.imul(g,J)|0,i=(i=i+Math.imul(g,X)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,X)|0,r=r+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,tt)|0;var Mt=(c+(r=r+Math.imul(h,nt)|0)|0)+((8191&(i=(i=i+Math.imul(h,rt)|0)+Math.imul(d,nt)|0))<<13)|0;c=((o=o+Math.imul(d,rt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(L,Q),i=(i=Math.imul(L,Y))+Math.imul(S,Q)|0,o=Math.imul(S,Y),r=r+Math.imul(x,F)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,V)|0,r=r+Math.imul(N,G)|0,i=(i=i+Math.imul(N,q)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,q)|0,r=r+Math.imul(b,J)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,X)|0,r=r+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,tt)|0,r=r+Math.imul(p,nt)|0,i=(i=i+Math.imul(p,rt)|0)+Math.imul(y,nt)|0,o=o+Math.imul(y,rt)|0;var At=(c+(r=r+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,at)|0)+Math.imul(d,ot)|0))<<13)|0;c=((o=o+Math.imul(d,at)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,Q),i=(i=Math.imul(C,Y))+Math.imul(D,Q)|0,o=Math.imul(D,Y),r=r+Math.imul(L,F)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(S,F)|0,o=o+Math.imul(S,V)|0,r=r+Math.imul(x,G)|0,i=(i=i+Math.imul(x,q)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,q)|0,r=r+Math.imul(N,J)|0,i=(i=i+Math.imul(N,X)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,X)|0,r=r+Math.imul(b,$)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,tt)|0,r=r+Math.imul(g,nt)|0,i=(i=i+Math.imul(g,rt)|0)+Math.imul(v,nt)|0,o=o+Math.imul(v,rt)|0,r=r+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,at)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,at)|0;var Nt=(c+(r=r+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(d,ut)|0))<<13)|0;c=((o=o+Math.imul(d,ct)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,r=Math.imul(z,Q),i=(i=Math.imul(z,Y))+Math.imul(P,Q)|0,o=Math.imul(P,Y),r=r+Math.imul(C,F)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(D,F)|0,o=o+Math.imul(D,V)|0,r=r+Math.imul(L,G)|0,i=(i=i+Math.imul(L,q)|0)+Math.imul(S,G)|0,o=o+Math.imul(S,q)|0,r=r+Math.imul(x,J)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,X)|0,r=r+Math.imul(N,$)|0,i=(i=i+Math.imul(N,tt)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,tt)|0,r=r+Math.imul(b,nt)|0,i=(i=i+Math.imul(b,rt)|0)+Math.imul(M,nt)|0,o=o+Math.imul(M,rt)|0,r=r+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,at)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,at)|0,r=r+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var It=(c+(r=r+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;c=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(B,Q),i=(i=Math.imul(B,Y))+Math.imul(R,Q)|0,o=Math.imul(R,Y),r=r+Math.imul(z,F)|0,i=(i=i+Math.imul(z,V)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,V)|0,r=r+Math.imul(C,G)|0,i=(i=i+Math.imul(C,q)|0)+Math.imul(D,G)|0,o=o+Math.imul(D,q)|0,r=r+Math.imul(L,J)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(S,J)|0,o=o+Math.imul(S,X)|0,r=r+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,r=r+Math.imul(N,nt)|0,i=(i=i+Math.imul(N,rt)|0)+Math.imul(I,nt)|0,o=o+Math.imul(I,rt)|0,r=r+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,at)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,at)|0,r=r+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,r=r+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,dt)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,dt)|0;var Et=(c+(r=r+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,yt)|0)+Math.imul(d,pt)|0))<<13)|0;c=((o=o+Math.imul(d,yt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(B,F),i=(i=Math.imul(B,V))+Math.imul(R,F)|0,o=Math.imul(R,V),r=r+Math.imul(z,G)|0,i=(i=i+Math.imul(z,q)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,q)|0,r=r+Math.imul(C,J)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(D,J)|0,o=o+Math.imul(D,X)|0,r=r+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,tt)|0,r=r+Math.imul(x,nt)|0,i=(i=i+Math.imul(x,rt)|0)+Math.imul(k,nt)|0,o=o+Math.imul(k,rt)|0,r=r+Math.imul(N,ot)|0,i=(i=i+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,r=r+Math.imul(b,ut)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(M,ut)|0,o=o+Math.imul(M,ct)|0,r=r+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,dt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,dt)|0;var xt=(c+(r=r+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(B,G),i=(i=Math.imul(B,q))+Math.imul(R,G)|0,o=Math.imul(R,q),r=r+Math.imul(z,J)|0,i=(i=i+Math.imul(z,X)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,X)|0,r=r+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,tt)|0,r=r+Math.imul(L,nt)|0,i=(i=i+Math.imul(L,rt)|0)+Math.imul(S,nt)|0,o=o+Math.imul(S,rt)|0,r=r+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,r=r+Math.imul(N,ut)|0,i=(i=i+Math.imul(N,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,r=r+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,dt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,dt)|0;var kt=(c+(r=r+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,yt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,yt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(B,J),i=(i=Math.imul(B,X))+Math.imul(R,J)|0,o=Math.imul(R,X),r=r+Math.imul(z,$)|0,i=(i=i+Math.imul(z,tt)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,tt)|0,r=r+Math.imul(C,nt)|0,i=(i=i+Math.imul(C,rt)|0)+Math.imul(D,nt)|0,o=o+Math.imul(D,rt)|0,r=r+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,at)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,at)|0,r=r+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,r=r+Math.imul(N,ht)|0,i=(i=i+Math.imul(N,dt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,dt)|0;var Tt=(c+(r=r+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,yt)|0)+Math.imul(M,pt)|0))<<13)|0;c=((o=o+Math.imul(M,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(B,$),i=(i=Math.imul(B,tt))+Math.imul(R,$)|0,o=Math.imul(R,tt),r=r+Math.imul(z,nt)|0,i=(i=i+Math.imul(z,rt)|0)+Math.imul(P,nt)|0,o=o+Math.imul(P,rt)|0,r=r+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,at)|0)+Math.imul(D,ot)|0,o=o+Math.imul(D,at)|0,r=r+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,ct)|0,r=r+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,dt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,dt)|0;var Lt=(c+(r=r+Math.imul(N,pt)|0)|0)+((8191&(i=(i=i+Math.imul(N,yt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,yt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,r=Math.imul(B,nt),i=(i=Math.imul(B,rt))+Math.imul(R,nt)|0,o=Math.imul(R,rt),r=r+Math.imul(z,ot)|0,i=(i=i+Math.imul(z,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,r=r+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(D,ut)|0,o=o+Math.imul(D,ct)|0,r=r+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,dt)|0)+Math.imul(S,ht)|0,o=o+Math.imul(S,dt)|0;var St=(c+(r=r+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,yt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(B,ot),i=(i=Math.imul(B,at))+Math.imul(R,ot)|0,o=Math.imul(R,at),r=r+Math.imul(z,ut)|0,i=(i=i+Math.imul(z,ct)|0)+Math.imul(P,ut)|0,o=o+Math.imul(P,ct)|0,r=r+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,dt)|0)+Math.imul(D,ht)|0,o=o+Math.imul(D,dt)|0;var jt=(c+(r=r+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,yt)|0)+Math.imul(S,pt)|0))<<13)|0;c=((o=o+Math.imul(S,yt)|0)+(i>>>13)|0)+(jt>>>26)|0,jt&=67108863,r=Math.imul(B,ut),i=(i=Math.imul(B,ct))+Math.imul(R,ut)|0,o=Math.imul(R,ct),r=r+Math.imul(z,ht)|0,i=(i=i+Math.imul(z,dt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,dt)|0;var Ct=(c+(r=r+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,yt)|0)+Math.imul(D,pt)|0))<<13)|0;c=((o=o+Math.imul(D,yt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,r=Math.imul(B,ht),i=(i=Math.imul(B,dt))+Math.imul(R,ht)|0,o=Math.imul(R,dt);var Dt=(c+(r=r+Math.imul(z,pt)|0)|0)+((8191&(i=(i=i+Math.imul(z,yt)|0)+Math.imul(P,pt)|0))<<13)|0;c=((o=o+Math.imul(P,yt)|0)+(i>>>13)|0)+(Dt>>>26)|0,Dt&=67108863;var Ot=(c+(r=Math.imul(B,pt))|0)+((8191&(i=(i=Math.imul(B,yt))+Math.imul(R,pt)|0))<<13)|0;return c=((o=Math.imul(R,yt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=mt,u[1]=gt,u[2]=vt,u[3]=wt,u[4]=bt,u[5]=Mt,u[6]=At,u[7]=Nt,u[8]=It,u[9]=Et,u[10]=xt,u[11]=kt,u[12]=Tt,u[13]=Lt,u[14]=St,u[15]=jt,u[16]=Ct,u[17]=Dt,u[18]=Ot,0!==c&&(u[19]=c,n.length++),n};function m(t,e,n){n.negative=e.negative^t.negative,n.length=t.length+e.length;for(var r=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}n.words[o]=s,r=a,a=i}return 0!==r?n.words[o]=r:n.length--,n._strip()}function g(t,e,n){return m(t,e,n)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var n=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):n<63?p(this,t,e):n<1024?m(this,t,e):g(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),g(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,i=0;i>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),n=0;n>>i&1}return e}(t);if(0===e.length)return new i(1);for(var n=this,r=0;r=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(e=0;e>>26-r}a&&(this.words[e]=a,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<