@smartledger/bsv 7.6.1 → 7.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bsv-gdaf.min.js CHANGED
@@ -14,7 +14,7 @@ Use Chrome, Firefox or Internet Explorer 11`)}var BU=ot().Buffer,id=globalThis.c
14
14
  `)}});var gI=k(pI=>{v();var dI=pI;dI.der=Sm();dI.pem=hI()});var Ac=k(vI=>{v();var kc=vI;kc.bignum=Cn();kc.define=HE().define;kc.base=Tc();kc.constants=gm();kc.decoders=aI();kc.encoders=gI()});var _I=k((d1e,bI)=>{"use strict";v();var Dn=Ac(),mI=Dn.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),lY=Dn.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),Im=Dn.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),hY=Dn.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(Im),this.key("subjectPublicKey").bitstr())}),dY=Dn.define("RelativeDistinguishedName",function(){this.setof(lY)}),pY=Dn.define("RDNSequence",function(){this.seqof(dY)}),yI=Dn.define("Name",function(){this.choice({rdnSequence:this.use(pY)})}),gY=Dn.define("Validity",function(){this.seq().obj(this.key("notBefore").use(mI),this.key("notAfter").use(mI))}),vY=Dn.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),mY=Dn.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(Im),this.key("issuer").use(yI),this.key("validity").use(gY),this.key("subject").use(yI),this.key("subjectPublicKeyInfo").use(hY),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(vY).optional())}),yY=Dn.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(mY),this.key("signatureAlgorithm").use(Im),this.key("signatureValue").bitstr())});bI.exports=yY});var SI=k(qn=>{"use strict";v();var Ln=Ac();qn.certificate=_I();var bY=Ln.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});qn.RSAPrivateKey=bY;var _Y=Ln.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});qn.RSAPublicKey=_Y;var wI=Ln.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),wY=Ln.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(wI),this.key("subjectPublicKey").bitstr())});qn.PublicKey=wY;var SY=Ln.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(wI),this.key("subjectPrivateKey").octstr())});qn.PrivateKey=SY;var xY=Ln.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});qn.EncryptedPrivateKey=xY;var EY=Ln.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});qn.DSAPrivateKey=EY;qn.DSAparam=Ln.define("DSAparam",function(){this.int()});var IY=Ln.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),OY=Ln.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(IY),this.key("publicKey").optional().explicit(1).bitstr())});qn.ECPrivateKey=OY;qn.signature=Ln.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})});var xI=k((m1e,AY)=>{AY.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}});var II=k((y1e,EI)=>{"use strict";v();var PY=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,TY=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,kY=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,RY=Yh(),BY=D2(),z2=ot().Buffer;EI.exports=function(e,t){var r=e.toString(),i=r.match(PY),n;if(i){var a="aes"+i[1],s=z2.from(i[2],"hex"),u=z2.from(i[3].replace(/[\r\n]/g,""),"base64"),c=RY(t,s.slice(0,8),parseInt(i[1],10)).key,l=[],m=BY.createDecipheriv(a,c,s);l.push(m.update(u)),l.push(m.final()),n=z2.concat(l)}else{var o=r.match(kY);n=z2.from(o[2].replace(/[\r\n]/g,""),"base64")}var w=r.match(TY)[1];return{tag:w,data:n}}});var Am=k((_1e,AI)=>{"use strict";v();var Ti=SI(),MY=xI(),CY=II(),NY=D2(),DY=Dv().pbkdf2Sync,Om=ot().Buffer;function LY(e,t){var r=e.algorithm.decrypt.kde.kdeparams.salt,i=parseInt(e.algorithm.decrypt.kde.kdeparams.iters.toString(),10),n=MY[e.algorithm.decrypt.cipher.algo.join(".")],o=e.algorithm.decrypt.cipher.iv,a=e.subjectPrivateKey,s=parseInt(n.split("-")[1],10)/8,u=DY(t,r,i,s,"sha1"),c=NY.createDecipheriv(n,u,o),l=[];return l.push(c.update(a)),l.push(c.final()),Om.concat(l)}function OI(e){var t;typeof e=="object"&&!Om.isBuffer(e)&&(t=e.passphrase,e=e.key),typeof e=="string"&&(e=Om.from(e));var r=CY(e,t),i=r.tag,n=r.data,o,a;switch(i){case"CERTIFICATE":a=Ti.certificate.decode(n,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(a||(a=Ti.PublicKey.decode(n,"der")),o=a.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Ti.RSAPublicKey.decode(a.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return a.subjectPrivateKey=a.subjectPublicKey,{type:"ec",data:a};case"1.2.840.10040.4.1":return a.algorithm.params.pub_key=Ti.DSAparam.decode(a.subjectPublicKey.data,"der"),{type:"dsa",data:a.algorithm.params};default:throw new Error("unknown key id "+o)}case"ENCRYPTED PRIVATE KEY":n=Ti.EncryptedPrivateKey.decode(n,"der"),n=LY(n,t);case"PRIVATE KEY":switch(a=Ti.PrivateKey.decode(n,"der"),o=a.algorithm.algorithm.join("."),o){case"1.2.840.113549.1.1.1":return Ti.RSAPrivateKey.decode(a.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:a.algorithm.curve,privateKey:Ti.ECPrivateKey.decode(a.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return a.algorithm.params.priv_key=Ti.DSAparam.decode(a.subjectPrivateKey,"der"),{type:"dsa",params:a.algorithm.params};default:throw new Error("unknown key id "+o)}case"RSA PUBLIC KEY":return Ti.RSAPublicKey.decode(n,"der");case"RSA PRIVATE KEY":return Ti.RSAPrivateKey.decode(n,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:Ti.DSAPrivateKey.decode(n,"der")};case"EC PRIVATE KEY":return n=Ti.ECPrivateKey.decode(n,"der"),{curve:n.parameters.value,privateKey:n.privateKey};default:throw new Error("unknown key type "+i)}}OI.signature=Ti.signature;AI.exports=OI});var Tm=k((S1e,PI)=>{v();var qY=Hh(),Pm=ot().Buffer;PI.exports=function(e,t){for(var r=Pm.alloc(0),i=0,n;r.length<t;)n=UY(i++),r=Pm.concat([r,qY("sha1").update(e).update(n).digest()]);return r.slice(0,t)};function UY(e){var t=Pm.allocUnsafe(4);return t.writeUInt32BE(e,0),t}});var km=k((E1e,TI)=>{v();TI.exports=function(t,r){for(var i=t.length,n=-1;++n<i;)t[n]^=r[n];return t}});var Rm=k((O1e,RI)=>{v();var kI=Cn(),FY=ot().Buffer;function HY(e,t){return FY.from(e.toRed(kI.mont(t.modulus)).redPow(new kI(t.publicExponent)).fromRed().toArray())}RI.exports=HY});var MI=k((BI,Bm)=>{v();(function(e,t){"use strict";function r(y,f){if(!y)throw new Error(f||"Assertion failed")}function i(y,f){y.super_=f;var p=function(){};p.prototype=f.prototype,y.prototype=new p,y.prototype.constructor=y}function n(y,f,p){if(n.isBN(y))return y;this.negative=0,this.words=null,this.length=0,this.red=null,y!==null&&((f==="le"||f==="be")&&(p=f,f=10),this._init(y||0,f||10,p||"be"))}typeof e=="object"?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Kt().Buffer}catch{}n.isBN=function(f){return f instanceof n?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===n.wordSize&&Array.isArray(f.words)},n.max=function(f,p){return f.cmp(p)>0?f:p},n.min=function(f,p){return f.cmp(p)<0?f:p},n.prototype._init=function(f,p,_){if(typeof f=="number")return this._initNumber(f,p,_);if(typeof f=="object")return this._initArray(f,p,_);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),f=f.toString().replace(/\s+/g,"");var x=0;f[0]==="-"&&(x++,this.negative=1),x<f.length&&(p===16?this._parseHex(f,x,_):(this._parseBase(f,p,x),_==="le"&&this._initArray(this.toArray(),p,_)))},n.prototype._initNumber=function(f,p,_){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(r(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),_==="le"&&this._initArray(this.toArray(),p,_)},n.prototype._initArray=function(f,p,_){if(r(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var x=0;x<this.length;x++)this.words[x]=0;var b,d,O=0;if(_==="be")for(x=f.length-1,b=0;x>=0;x-=3)d=f[x]|f[x-1]<<8|f[x-2]<<16,this.words[b]|=d<<O&67108863,this.words[b+1]=d>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);else if(_==="le")for(x=0,b=0;x<f.length;x+=3)d=f[x]|f[x+1]<<8|f[x+2]<<16,this.words[b]|=d<<O&67108863,this.words[b+1]=d>>>26-O&67108863,O+=24,O>=26&&(O-=26,b++);return this._strip()};function a(y,f){var p=y.charCodeAt(f);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+y)}function s(y,f,p){var _=a(y,p);return p-1>=f&&(_|=a(y,p-1)<<4),_}n.prototype._parseHex=function(f,p,_){this.length=Math.ceil((f.length-p)/6),this.words=new Array(this.length);for(var x=0;x<this.length;x++)this.words[x]=0;var b=0,d=0,O;if(_==="be")for(x=f.length-1;x>=p;x-=2)O=s(f,p,x)<<b,this.words[d]|=O&67108863,b>=18?(b-=18,d+=1,this.words[d]|=O>>>26):b+=8;else{var T=f.length-p;for(x=T%2===0?p+1:p;x<f.length;x+=2)O=s(f,p,x)<<b,this.words[d]|=O&67108863,b>=18?(b-=18,d+=1,this.words[d]|=O>>>26):b+=8}this._strip()};function u(y,f,p,_){for(var x=0,b=0,d=Math.min(y.length,p),O=f;O<d;O++){var T=y.charCodeAt(O)-48;x*=_,T>=49?b=T-49+10:T>=17?b=T-17+10:b=T,r(T>=0&&b<_,"Invalid character"),x+=b}return x}n.prototype._parseBase=function(f,p,_){this.words=[0],this.length=1;for(var x=0,b=1;b<=67108863;b*=p)x++;x--,b=b/p|0;for(var d=f.length-_,O=d%x,T=Math.min(d,d-O)+_,S=0,R=_;R<T;R+=x)S=u(f,R,R+x,p),this.imuln(b),this.words[0]+S<67108864?this.words[0]+=S:this._iaddn(S);if(O!==0){var Y=1;for(S=u(f,R,f.length,p),R=0;R<O;R++)Y*=p;this.imuln(Y),this.words[0]+S<67108864?this.words[0]+=S:this._iaddn(S)}this._strip()},n.prototype.copy=function(f){f.words=new Array(this.length);for(var p=0;p<this.length;p++)f.words[p]=this.words[p];f.length=this.length,f.negative=this.negative,f.red=this.red};function c(y,f){y.words=f.words,y.length=f.length,y.negative=f.negative,y.red=f.red}if(n.prototype._move=function(f){c(f,this)},n.prototype.clone=function(){var f=new n(null);return this.copy(f),f},n.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch{n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var m=["","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"],w=[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],E=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(f,p){f=f||10,p=p|0||1;var _;if(f===16||f==="hex"){_="";for(var x=0,b=0,d=0;d<this.length;d++){var O=this.words[d],T=((O<<x|b)&16777215).toString(16);b=O>>>24-x&16777215,x+=2,x>=26&&(x-=26,d--),b!==0||d!==this.length-1?_=m[6-T.length]+T+_:_=T+_}for(b!==0&&(_=b.toString(16)+_);_.length%p!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}if(f===(f|0)&&f>=2&&f<=36){var S=w[f],R=E[f];_="";var Y=this.clone();for(Y.negative=0;!Y.isZero();){var X=Y.modrn(R).toString(f);Y=Y.idivn(R),Y.isZero()?_=X+_:_=m[S-X.length]+X+_}for(this.isZero()&&(_="0"+_);_.length%p!==0;)_="0"+_;return this.negative!==0&&(_="-"+_),_}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(f,p){return this.toArrayLike(o,f,p)}),n.prototype.toArray=function(f,p){return this.toArrayLike(Array,f,p)};var P=function(f,p){return f.allocUnsafe?f.allocUnsafe(p):new f(p)};n.prototype.toArrayLike=function(f,p,_){this._strip();var x=this.byteLength(),b=_||Math.max(1,x);r(x<=b,"byte array longer than desired length"),r(b>0,"Requested array length <= 0");var d=P(f,b),O=p==="le"?"LE":"BE";return this["_toArrayLike"+O](d,x),d},n.prototype._toArrayLikeLE=function(f,p){for(var _=0,x=0,b=0,d=0;b<this.length;b++){var O=this.words[b]<<d|x;f[_++]=O&255,_<f.length&&(f[_++]=O>>8&255),_<f.length&&(f[_++]=O>>16&255),d===6?(_<f.length&&(f[_++]=O>>24&255),x=0,d=0):(x=O>>>24,d+=2)}if(_<f.length)for(f[_++]=x;_<f.length;)f[_++]=0},n.prototype._toArrayLikeBE=function(f,p){for(var _=f.length-1,x=0,b=0,d=0;b<this.length;b++){var O=this.words[b]<<d|x;f[_--]=O&255,_>=0&&(f[_--]=O>>8&255),_>=0&&(f[_--]=O>>16&255),d===6?(_>=0&&(f[_--]=O>>24&255),x=0,d=0):(x=O>>>24,d+=2)}if(_>=0)for(f[_--]=x;_>=0;)f[_--]=0},Math.clz32?n.prototype._countBits=function(f){return 32-Math.clz32(f)}:n.prototype._countBits=function(f){var p=f,_=0;return p>=4096&&(_+=13,p>>>=13),p>=64&&(_+=7,p>>>=7),p>=8&&(_+=4,p>>>=4),p>=2&&(_+=2,p>>>=2),_+p},n.prototype._zeroBits=function(f){if(f===0)return 26;var p=f,_=0;return(p&8191)===0&&(_+=13,p>>>=13),(p&127)===0&&(_+=7,p>>>=7),(p&15)===0&&(_+=4,p>>>=4),(p&3)===0&&(_+=2,p>>>=2),(p&1)===0&&_++,_},n.prototype.bitLength=function(){var f=this.words[this.length-1],p=this._countBits(f);return(this.length-1)*26+p};function M(y){for(var f=new Array(y.bitLength()),p=0;p<f.length;p++){var _=p/26|0,x=p%26;f[p]=y.words[_]>>>x&1}return f}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,p=0;p<this.length;p++){var _=this._zeroBits(this.words[p]);if(f+=_,_!==26)break}return f},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},n.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return this.negative!==0},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var p=0;p<f.length;p++)this.words[p]=this.words[p]|f.words[p];return this._strip()},n.prototype.ior=function(f){return r((this.negative|f.negative)===0),this.iuor(f)},n.prototype.or=function(f){return this.length>f.length?this.clone().ior(f):f.clone().ior(this)},n.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},n.prototype.iuand=function(f){var p;this.length>f.length?p=f:p=this;for(var _=0;_<p.length;_++)this.words[_]=this.words[_]&f.words[_];return this.length=p.length,this._strip()},n.prototype.iand=function(f){return r((this.negative|f.negative)===0),this.iuand(f)},n.prototype.and=function(f){return this.length>f.length?this.clone().iand(f):f.clone().iand(this)},n.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},n.prototype.iuxor=function(f){var p,_;this.length>f.length?(p=this,_=f):(p=f,_=this);for(var x=0;x<_.length;x++)this.words[x]=p.words[x]^_.words[x];if(this!==p)for(;x<p.length;x++)this.words[x]=p.words[x];return this.length=p.length,this._strip()},n.prototype.ixor=function(f){return r((this.negative|f.negative)===0),this.iuxor(f)},n.prototype.xor=function(f){return this.length>f.length?this.clone().ixor(f):f.clone().ixor(this)},n.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},n.prototype.inotn=function(f){r(typeof f=="number"&&f>=0);var p=Math.ceil(f/26)|0,_=f%26;this._expand(p),_>0&&p--;for(var x=0;x<p;x++)this.words[x]=~this.words[x]&67108863;return _>0&&(this.words[x]=~this.words[x]&67108863>>26-_),this._strip()},n.prototype.notn=function(f){return this.clone().inotn(f)},n.prototype.setn=function(f,p){r(typeof f=="number"&&f>=0);var _=f/26|0,x=f%26;return this._expand(_+1),p?this.words[_]=this.words[_]|1<<x:this.words[_]=this.words[_]&~(1<<x),this._strip()},n.prototype.iadd=function(f){var p;if(this.negative!==0&&f.negative===0)return this.negative=0,p=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,p=this.isub(f),f.negative=1,p._normSign();var _,x;this.length>f.length?(_=this,x=f):(_=f,x=this);for(var b=0,d=0;d<x.length;d++)p=(_.words[d]|0)+(x.words[d]|0)+b,this.words[d]=p&67108863,b=p>>>26;for(;b!==0&&d<_.length;d++)p=(_.words[d]|0)+b,this.words[d]=p&67108863,b=p>>>26;if(this.length=_.length,b!==0)this.words[this.length]=b,this.length++;else if(_!==this)for(;d<_.length;d++)this.words[d]=_.words[d];return this},n.prototype.add=function(f){var p;return f.negative!==0&&this.negative===0?(f.negative=0,p=this.sub(f),f.negative^=1,p):f.negative===0&&this.negative!==0?(this.negative=0,p=f.sub(this),this.negative=1,p):this.length>f.length?this.clone().iadd(f):f.clone().iadd(this)},n.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var p=this.iadd(f);return f.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var _=this.cmp(f);if(_===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,b;_>0?(x=this,b=f):(x=f,b=this);for(var d=0,O=0;O<b.length;O++)p=(x.words[O]|0)-(b.words[O]|0)+d,d=p>>26,this.words[O]=p&67108863;for(;d!==0&&O<x.length;O++)p=(x.words[O]|0)+d,d=p>>26,this.words[O]=p&67108863;if(d===0&&O<x.length&&x!==this)for(;O<x.length;O++)this.words[O]=x.words[O];return this.length=Math.max(this.length,O),x!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(f){return this.clone().isub(f)};function D(y,f,p){p.negative=f.negative^y.negative;var _=y.length+f.length|0;p.length=_,_=_-1|0;var x=y.words[0]|0,b=f.words[0]|0,d=x*b,O=d&67108863,T=d/67108864|0;p.words[0]=O;for(var S=1;S<_;S++){for(var R=T>>>26,Y=T&67108863,X=Math.min(S,f.length-1),ne=Math.max(0,S-y.length+1);ne<=X;ne++){var ce=S-ne|0;x=y.words[ce]|0,b=f.words[ne]|0,d=x*b+Y,R+=d/67108864|0,Y=d&67108863}p.words[S]=Y|0,T=R|0}return T!==0?p.words[S]=T|0:p.length--,p._strip()}var L=function(f,p,_){var x=f.words,b=p.words,d=_.words,O=0,T,S,R,Y=x[0]|0,X=Y&8191,ne=Y>>>13,ce=x[1]|0,pe=ce&8191,q=ce>>>13,W=x[2]|0,$=W&8191,ee=W>>>13,se=x[3]|0,ue=se&8191,le=se>>>13,Pe=x[4]|0,ge=Pe&8191,ve=Pe>>>13,sr=x[5]|0,xe=sr&8191,ye=sr>>>13,Be=x[6]|0,be=Be&8191,_e=Be>>>13,Qi=x[7]|0,Ce=Qi&8191,Re=Qi>>>13,Js=x[8]|0,De=Js&8191,qe=Js>>>13,Wl=x[9]|0,Ue=Wl&8191,Fe=Wl>>>13,Yl=b[0]|0,He=Yl&8191,je=Yl>>>13,$l=b[1]|0,ze=$l&8191,Ke=$l>>>13,Xl=b[2]|0,Ve=Xl&8191,Ge=Xl>>>13,Jl=b[3]|0,Ze=Jl&8191,We=Jl>>>13,Ql=b[4]|0,Ye=Ql&8191,$e=Ql>>>13,eh=b[5]|0,Xe=eh&8191,Je=eh>>>13,th=b[6]|0,Qe=th&8191,et=th>>>13,rh=b[7]|0,tt=rh&8191,rt=rh>>>13,ih=b[8]|0,it=ih&8191,nt=ih>>>13,Gf=b[9]|0,Jt=Gf&8191,Qt=Gf>>>13;_.negative=f.negative^p.negative,_.length=19,T=Math.imul(X,He),S=Math.imul(X,je),S=S+Math.imul(ne,He)|0,R=Math.imul(ne,je);var Qs=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(Qs>>>26)|0,Qs&=67108863,T=Math.imul(pe,He),S=Math.imul(pe,je),S=S+Math.imul(q,He)|0,R=Math.imul(q,je),T=T+Math.imul(X,ze)|0,S=S+Math.imul(X,Ke)|0,S=S+Math.imul(ne,ze)|0,R=R+Math.imul(ne,Ke)|0;var eu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(eu>>>26)|0,eu&=67108863,T=Math.imul($,He),S=Math.imul($,je),S=S+Math.imul(ee,He)|0,R=Math.imul(ee,je),T=T+Math.imul(pe,ze)|0,S=S+Math.imul(pe,Ke)|0,S=S+Math.imul(q,ze)|0,R=R+Math.imul(q,Ke)|0,T=T+Math.imul(X,Ve)|0,S=S+Math.imul(X,Ge)|0,S=S+Math.imul(ne,Ve)|0,R=R+Math.imul(ne,Ge)|0;var tu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(tu>>>26)|0,tu&=67108863,T=Math.imul(ue,He),S=Math.imul(ue,je),S=S+Math.imul(le,He)|0,R=Math.imul(le,je),T=T+Math.imul($,ze)|0,S=S+Math.imul($,Ke)|0,S=S+Math.imul(ee,ze)|0,R=R+Math.imul(ee,Ke)|0,T=T+Math.imul(pe,Ve)|0,S=S+Math.imul(pe,Ge)|0,S=S+Math.imul(q,Ve)|0,R=R+Math.imul(q,Ge)|0,T=T+Math.imul(X,Ze)|0,S=S+Math.imul(X,We)|0,S=S+Math.imul(ne,Ze)|0,R=R+Math.imul(ne,We)|0;var ru=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(ru>>>26)|0,ru&=67108863,T=Math.imul(ge,He),S=Math.imul(ge,je),S=S+Math.imul(ve,He)|0,R=Math.imul(ve,je),T=T+Math.imul(ue,ze)|0,S=S+Math.imul(ue,Ke)|0,S=S+Math.imul(le,ze)|0,R=R+Math.imul(le,Ke)|0,T=T+Math.imul($,Ve)|0,S=S+Math.imul($,Ge)|0,S=S+Math.imul(ee,Ve)|0,R=R+Math.imul(ee,Ge)|0,T=T+Math.imul(pe,Ze)|0,S=S+Math.imul(pe,We)|0,S=S+Math.imul(q,Ze)|0,R=R+Math.imul(q,We)|0,T=T+Math.imul(X,Ye)|0,S=S+Math.imul(X,$e)|0,S=S+Math.imul(ne,Ye)|0,R=R+Math.imul(ne,$e)|0;var iu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(iu>>>26)|0,iu&=67108863,T=Math.imul(xe,He),S=Math.imul(xe,je),S=S+Math.imul(ye,He)|0,R=Math.imul(ye,je),T=T+Math.imul(ge,ze)|0,S=S+Math.imul(ge,Ke)|0,S=S+Math.imul(ve,ze)|0,R=R+Math.imul(ve,Ke)|0,T=T+Math.imul(ue,Ve)|0,S=S+Math.imul(ue,Ge)|0,S=S+Math.imul(le,Ve)|0,R=R+Math.imul(le,Ge)|0,T=T+Math.imul($,Ze)|0,S=S+Math.imul($,We)|0,S=S+Math.imul(ee,Ze)|0,R=R+Math.imul(ee,We)|0,T=T+Math.imul(pe,Ye)|0,S=S+Math.imul(pe,$e)|0,S=S+Math.imul(q,Ye)|0,R=R+Math.imul(q,$e)|0,T=T+Math.imul(X,Xe)|0,S=S+Math.imul(X,Je)|0,S=S+Math.imul(ne,Xe)|0,R=R+Math.imul(ne,Je)|0;var nu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(nu>>>26)|0,nu&=67108863,T=Math.imul(be,He),S=Math.imul(be,je),S=S+Math.imul(_e,He)|0,R=Math.imul(_e,je),T=T+Math.imul(xe,ze)|0,S=S+Math.imul(xe,Ke)|0,S=S+Math.imul(ye,ze)|0,R=R+Math.imul(ye,Ke)|0,T=T+Math.imul(ge,Ve)|0,S=S+Math.imul(ge,Ge)|0,S=S+Math.imul(ve,Ve)|0,R=R+Math.imul(ve,Ge)|0,T=T+Math.imul(ue,Ze)|0,S=S+Math.imul(ue,We)|0,S=S+Math.imul(le,Ze)|0,R=R+Math.imul(le,We)|0,T=T+Math.imul($,Ye)|0,S=S+Math.imul($,$e)|0,S=S+Math.imul(ee,Ye)|0,R=R+Math.imul(ee,$e)|0,T=T+Math.imul(pe,Xe)|0,S=S+Math.imul(pe,Je)|0,S=S+Math.imul(q,Xe)|0,R=R+Math.imul(q,Je)|0,T=T+Math.imul(X,Qe)|0,S=S+Math.imul(X,et)|0,S=S+Math.imul(ne,Qe)|0,R=R+Math.imul(ne,et)|0;var ou=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(ou>>>26)|0,ou&=67108863,T=Math.imul(Ce,He),S=Math.imul(Ce,je),S=S+Math.imul(Re,He)|0,R=Math.imul(Re,je),T=T+Math.imul(be,ze)|0,S=S+Math.imul(be,Ke)|0,S=S+Math.imul(_e,ze)|0,R=R+Math.imul(_e,Ke)|0,T=T+Math.imul(xe,Ve)|0,S=S+Math.imul(xe,Ge)|0,S=S+Math.imul(ye,Ve)|0,R=R+Math.imul(ye,Ge)|0,T=T+Math.imul(ge,Ze)|0,S=S+Math.imul(ge,We)|0,S=S+Math.imul(ve,Ze)|0,R=R+Math.imul(ve,We)|0,T=T+Math.imul(ue,Ye)|0,S=S+Math.imul(ue,$e)|0,S=S+Math.imul(le,Ye)|0,R=R+Math.imul(le,$e)|0,T=T+Math.imul($,Xe)|0,S=S+Math.imul($,Je)|0,S=S+Math.imul(ee,Xe)|0,R=R+Math.imul(ee,Je)|0,T=T+Math.imul(pe,Qe)|0,S=S+Math.imul(pe,et)|0,S=S+Math.imul(q,Qe)|0,R=R+Math.imul(q,et)|0,T=T+Math.imul(X,tt)|0,S=S+Math.imul(X,rt)|0,S=S+Math.imul(ne,tt)|0,R=R+Math.imul(ne,rt)|0;var au=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(au>>>26)|0,au&=67108863,T=Math.imul(De,He),S=Math.imul(De,je),S=S+Math.imul(qe,He)|0,R=Math.imul(qe,je),T=T+Math.imul(Ce,ze)|0,S=S+Math.imul(Ce,Ke)|0,S=S+Math.imul(Re,ze)|0,R=R+Math.imul(Re,Ke)|0,T=T+Math.imul(be,Ve)|0,S=S+Math.imul(be,Ge)|0,S=S+Math.imul(_e,Ve)|0,R=R+Math.imul(_e,Ge)|0,T=T+Math.imul(xe,Ze)|0,S=S+Math.imul(xe,We)|0,S=S+Math.imul(ye,Ze)|0,R=R+Math.imul(ye,We)|0,T=T+Math.imul(ge,Ye)|0,S=S+Math.imul(ge,$e)|0,S=S+Math.imul(ve,Ye)|0,R=R+Math.imul(ve,$e)|0,T=T+Math.imul(ue,Xe)|0,S=S+Math.imul(ue,Je)|0,S=S+Math.imul(le,Xe)|0,R=R+Math.imul(le,Je)|0,T=T+Math.imul($,Qe)|0,S=S+Math.imul($,et)|0,S=S+Math.imul(ee,Qe)|0,R=R+Math.imul(ee,et)|0,T=T+Math.imul(pe,tt)|0,S=S+Math.imul(pe,rt)|0,S=S+Math.imul(q,tt)|0,R=R+Math.imul(q,rt)|0,T=T+Math.imul(X,it)|0,S=S+Math.imul(X,nt)|0,S=S+Math.imul(ne,it)|0,R=R+Math.imul(ne,nt)|0;var su=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(su>>>26)|0,su&=67108863,T=Math.imul(Ue,He),S=Math.imul(Ue,je),S=S+Math.imul(Fe,He)|0,R=Math.imul(Fe,je),T=T+Math.imul(De,ze)|0,S=S+Math.imul(De,Ke)|0,S=S+Math.imul(qe,ze)|0,R=R+Math.imul(qe,Ke)|0,T=T+Math.imul(Ce,Ve)|0,S=S+Math.imul(Ce,Ge)|0,S=S+Math.imul(Re,Ve)|0,R=R+Math.imul(Re,Ge)|0,T=T+Math.imul(be,Ze)|0,S=S+Math.imul(be,We)|0,S=S+Math.imul(_e,Ze)|0,R=R+Math.imul(_e,We)|0,T=T+Math.imul(xe,Ye)|0,S=S+Math.imul(xe,$e)|0,S=S+Math.imul(ye,Ye)|0,R=R+Math.imul(ye,$e)|0,T=T+Math.imul(ge,Xe)|0,S=S+Math.imul(ge,Je)|0,S=S+Math.imul(ve,Xe)|0,R=R+Math.imul(ve,Je)|0,T=T+Math.imul(ue,Qe)|0,S=S+Math.imul(ue,et)|0,S=S+Math.imul(le,Qe)|0,R=R+Math.imul(le,et)|0,T=T+Math.imul($,tt)|0,S=S+Math.imul($,rt)|0,S=S+Math.imul(ee,tt)|0,R=R+Math.imul(ee,rt)|0,T=T+Math.imul(pe,it)|0,S=S+Math.imul(pe,nt)|0,S=S+Math.imul(q,it)|0,R=R+Math.imul(q,nt)|0,T=T+Math.imul(X,Jt)|0,S=S+Math.imul(X,Qt)|0,S=S+Math.imul(ne,Jt)|0,R=R+Math.imul(ne,Qt)|0;var uu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(uu>>>26)|0,uu&=67108863,T=Math.imul(Ue,ze),S=Math.imul(Ue,Ke),S=S+Math.imul(Fe,ze)|0,R=Math.imul(Fe,Ke),T=T+Math.imul(De,Ve)|0,S=S+Math.imul(De,Ge)|0,S=S+Math.imul(qe,Ve)|0,R=R+Math.imul(qe,Ge)|0,T=T+Math.imul(Ce,Ze)|0,S=S+Math.imul(Ce,We)|0,S=S+Math.imul(Re,Ze)|0,R=R+Math.imul(Re,We)|0,T=T+Math.imul(be,Ye)|0,S=S+Math.imul(be,$e)|0,S=S+Math.imul(_e,Ye)|0,R=R+Math.imul(_e,$e)|0,T=T+Math.imul(xe,Xe)|0,S=S+Math.imul(xe,Je)|0,S=S+Math.imul(ye,Xe)|0,R=R+Math.imul(ye,Je)|0,T=T+Math.imul(ge,Qe)|0,S=S+Math.imul(ge,et)|0,S=S+Math.imul(ve,Qe)|0,R=R+Math.imul(ve,et)|0,T=T+Math.imul(ue,tt)|0,S=S+Math.imul(ue,rt)|0,S=S+Math.imul(le,tt)|0,R=R+Math.imul(le,rt)|0,T=T+Math.imul($,it)|0,S=S+Math.imul($,nt)|0,S=S+Math.imul(ee,it)|0,R=R+Math.imul(ee,nt)|0,T=T+Math.imul(pe,Jt)|0,S=S+Math.imul(pe,Qt)|0,S=S+Math.imul(q,Jt)|0,R=R+Math.imul(q,Qt)|0;var fu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(fu>>>26)|0,fu&=67108863,T=Math.imul(Ue,Ve),S=Math.imul(Ue,Ge),S=S+Math.imul(Fe,Ve)|0,R=Math.imul(Fe,Ge),T=T+Math.imul(De,Ze)|0,S=S+Math.imul(De,We)|0,S=S+Math.imul(qe,Ze)|0,R=R+Math.imul(qe,We)|0,T=T+Math.imul(Ce,Ye)|0,S=S+Math.imul(Ce,$e)|0,S=S+Math.imul(Re,Ye)|0,R=R+Math.imul(Re,$e)|0,T=T+Math.imul(be,Xe)|0,S=S+Math.imul(be,Je)|0,S=S+Math.imul(_e,Xe)|0,R=R+Math.imul(_e,Je)|0,T=T+Math.imul(xe,Qe)|0,S=S+Math.imul(xe,et)|0,S=S+Math.imul(ye,Qe)|0,R=R+Math.imul(ye,et)|0,T=T+Math.imul(ge,tt)|0,S=S+Math.imul(ge,rt)|0,S=S+Math.imul(ve,tt)|0,R=R+Math.imul(ve,rt)|0,T=T+Math.imul(ue,it)|0,S=S+Math.imul(ue,nt)|0,S=S+Math.imul(le,it)|0,R=R+Math.imul(le,nt)|0,T=T+Math.imul($,Jt)|0,S=S+Math.imul($,Qt)|0,S=S+Math.imul(ee,Jt)|0,R=R+Math.imul(ee,Qt)|0;var cu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(cu>>>26)|0,cu&=67108863,T=Math.imul(Ue,Ze),S=Math.imul(Ue,We),S=S+Math.imul(Fe,Ze)|0,R=Math.imul(Fe,We),T=T+Math.imul(De,Ye)|0,S=S+Math.imul(De,$e)|0,S=S+Math.imul(qe,Ye)|0,R=R+Math.imul(qe,$e)|0,T=T+Math.imul(Ce,Xe)|0,S=S+Math.imul(Ce,Je)|0,S=S+Math.imul(Re,Xe)|0,R=R+Math.imul(Re,Je)|0,T=T+Math.imul(be,Qe)|0,S=S+Math.imul(be,et)|0,S=S+Math.imul(_e,Qe)|0,R=R+Math.imul(_e,et)|0,T=T+Math.imul(xe,tt)|0,S=S+Math.imul(xe,rt)|0,S=S+Math.imul(ye,tt)|0,R=R+Math.imul(ye,rt)|0,T=T+Math.imul(ge,it)|0,S=S+Math.imul(ge,nt)|0,S=S+Math.imul(ve,it)|0,R=R+Math.imul(ve,nt)|0,T=T+Math.imul(ue,Jt)|0,S=S+Math.imul(ue,Qt)|0,S=S+Math.imul(le,Jt)|0,R=R+Math.imul(le,Qt)|0;var lu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(lu>>>26)|0,lu&=67108863,T=Math.imul(Ue,Ye),S=Math.imul(Ue,$e),S=S+Math.imul(Fe,Ye)|0,R=Math.imul(Fe,$e),T=T+Math.imul(De,Xe)|0,S=S+Math.imul(De,Je)|0,S=S+Math.imul(qe,Xe)|0,R=R+Math.imul(qe,Je)|0,T=T+Math.imul(Ce,Qe)|0,S=S+Math.imul(Ce,et)|0,S=S+Math.imul(Re,Qe)|0,R=R+Math.imul(Re,et)|0,T=T+Math.imul(be,tt)|0,S=S+Math.imul(be,rt)|0,S=S+Math.imul(_e,tt)|0,R=R+Math.imul(_e,rt)|0,T=T+Math.imul(xe,it)|0,S=S+Math.imul(xe,nt)|0,S=S+Math.imul(ye,it)|0,R=R+Math.imul(ye,nt)|0,T=T+Math.imul(ge,Jt)|0,S=S+Math.imul(ge,Qt)|0,S=S+Math.imul(ve,Jt)|0,R=R+Math.imul(ve,Qt)|0;var hu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(hu>>>26)|0,hu&=67108863,T=Math.imul(Ue,Xe),S=Math.imul(Ue,Je),S=S+Math.imul(Fe,Xe)|0,R=Math.imul(Fe,Je),T=T+Math.imul(De,Qe)|0,S=S+Math.imul(De,et)|0,S=S+Math.imul(qe,Qe)|0,R=R+Math.imul(qe,et)|0,T=T+Math.imul(Ce,tt)|0,S=S+Math.imul(Ce,rt)|0,S=S+Math.imul(Re,tt)|0,R=R+Math.imul(Re,rt)|0,T=T+Math.imul(be,it)|0,S=S+Math.imul(be,nt)|0,S=S+Math.imul(_e,it)|0,R=R+Math.imul(_e,nt)|0,T=T+Math.imul(xe,Jt)|0,S=S+Math.imul(xe,Qt)|0,S=S+Math.imul(ye,Jt)|0,R=R+Math.imul(ye,Qt)|0;var du=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(du>>>26)|0,du&=67108863,T=Math.imul(Ue,Qe),S=Math.imul(Ue,et),S=S+Math.imul(Fe,Qe)|0,R=Math.imul(Fe,et),T=T+Math.imul(De,tt)|0,S=S+Math.imul(De,rt)|0,S=S+Math.imul(qe,tt)|0,R=R+Math.imul(qe,rt)|0,T=T+Math.imul(Ce,it)|0,S=S+Math.imul(Ce,nt)|0,S=S+Math.imul(Re,it)|0,R=R+Math.imul(Re,nt)|0,T=T+Math.imul(be,Jt)|0,S=S+Math.imul(be,Qt)|0,S=S+Math.imul(_e,Jt)|0,R=R+Math.imul(_e,Qt)|0;var pu=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(pu>>>26)|0,pu&=67108863,T=Math.imul(Ue,tt),S=Math.imul(Ue,rt),S=S+Math.imul(Fe,tt)|0,R=Math.imul(Fe,rt),T=T+Math.imul(De,it)|0,S=S+Math.imul(De,nt)|0,S=S+Math.imul(qe,it)|0,R=R+Math.imul(qe,nt)|0,T=T+Math.imul(Ce,Jt)|0,S=S+Math.imul(Ce,Qt)|0,S=S+Math.imul(Re,Jt)|0,R=R+Math.imul(Re,Qt)|0;var M5=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(M5>>>26)|0,M5&=67108863,T=Math.imul(Ue,it),S=Math.imul(Ue,nt),S=S+Math.imul(Fe,it)|0,R=Math.imul(Fe,nt),T=T+Math.imul(De,Jt)|0,S=S+Math.imul(De,Qt)|0,S=S+Math.imul(qe,Jt)|0,R=R+Math.imul(qe,Qt)|0;var C5=(O+T|0)+((S&8191)<<13)|0;O=(R+(S>>>13)|0)+(C5>>>26)|0,C5&=67108863,T=Math.imul(Ue,Jt),S=Math.imul(Ue,Qt),S=S+Math.imul(Fe,Jt)|0,R=Math.imul(Fe,Qt);var N5=(O+T|0)+((S&8191)<<13)|0;return O=(R+(S>>>13)|0)+(N5>>>26)|0,N5&=67108863,d[0]=Qs,d[1]=eu,d[2]=tu,d[3]=ru,d[4]=iu,d[5]=nu,d[6]=ou,d[7]=au,d[8]=su,d[9]=uu,d[10]=fu,d[11]=cu,d[12]=lu,d[13]=hu,d[14]=du,d[15]=pu,d[16]=M5,d[17]=C5,d[18]=N5,O!==0&&(d[19]=O,_.length++),_};Math.imul||(L=D);function U(y,f,p){p.negative=f.negative^y.negative,p.length=y.length+f.length;for(var _=0,x=0,b=0;b<p.length-1;b++){var d=x;x=0;for(var O=_&67108863,T=Math.min(b,f.length-1),S=Math.max(0,b-y.length+1);S<=T;S++){var R=b-S,Y=y.words[R]|0,X=f.words[S]|0,ne=Y*X,ce=ne&67108863;d=d+(ne/67108864|0)|0,ce=ce+O|0,O=ce&67108863,d=d+(ce>>>26)|0,x+=d>>>26,d&=67108863}p.words[b]=O,_=d,d=x}return _!==0?p.words[b]=_:p.length--,p._strip()}function K(y,f,p){return U(y,f,p)}n.prototype.mulTo=function(f,p){var _,x=this.length+f.length;return this.length===10&&f.length===10?_=L(this,f,p):x<63?_=D(this,f,p):x<1024?_=U(this,f,p):_=K(this,f,p),_};function C(y,f){this.x=y,this.y=f}C.prototype.makeRBT=function(f){for(var p=new Array(f),_=n.prototype._countBits(f)-1,x=0;x<f;x++)p[x]=this.revBin(x,_,f);return p},C.prototype.revBin=function(f,p,_){if(f===0||f===_-1)return f;for(var x=0,b=0;b<p;b++)x|=(f&1)<<p-b-1,f>>=1;return x},C.prototype.permute=function(f,p,_,x,b,d){for(var O=0;O<d;O++)x[O]=p[f[O]],b[O]=_[f[O]]},C.prototype.transform=function(f,p,_,x,b,d){this.permute(d,f,p,_,x,b);for(var O=1;O<b;O<<=1)for(var T=O<<1,S=Math.cos(2*Math.PI/T),R=Math.sin(2*Math.PI/T),Y=0;Y<b;Y+=T)for(var X=S,ne=R,ce=0;ce<O;ce++){var pe=_[Y+ce],q=x[Y+ce],W=_[Y+ce+O],$=x[Y+ce+O],ee=X*W-ne*$;$=X*$+ne*W,W=ee,_[Y+ce]=pe+W,x[Y+ce]=q+$,_[Y+ce+O]=pe-W,x[Y+ce+O]=q-$,ce!==T&&(ee=S*X-R*ne,ne=S*ne+R*X,X=ee)}},C.prototype.guessLen13b=function(f,p){var _=Math.max(p,f)|1,x=_&1,b=0;for(_=_/2|0;_;_=_>>>1)b++;return 1<<b+1+x},C.prototype.conjugate=function(f,p,_){if(!(_<=1))for(var x=0;x<_/2;x++){var b=f[x];f[x]=f[_-x-1],f[_-x-1]=b,b=p[x],p[x]=-p[_-x-1],p[_-x-1]=-b}},C.prototype.normalize13b=function(f,p){for(var _=0,x=0;x<p/2;x++){var b=Math.round(f[2*x+1]/p)*8192+Math.round(f[2*x]/p)+_;f[x]=b&67108863,b<67108864?_=0:_=b/67108864|0}return f},C.prototype.convert13b=function(f,p,_,x){for(var b=0,d=0;d<p;d++)b=b+(f[d]|0),_[2*d]=b&8191,b=b>>>13,_[2*d+1]=b&8191,b=b>>>13;for(d=2*p;d<x;++d)_[d]=0;r(b===0),r((b&-8192)===0)},C.prototype.stub=function(f){for(var p=new Array(f),_=0;_<f;_++)p[_]=0;return p},C.prototype.mulp=function(f,p,_){var x=2*this.guessLen13b(f.length,p.length),b=this.makeRBT(x),d=this.stub(x),O=new Array(x),T=new Array(x),S=new Array(x),R=new Array(x),Y=new Array(x),X=new Array(x),ne=_.words;ne.length=x,this.convert13b(f.words,f.length,O,x),this.convert13b(p.words,p.length,R,x),this.transform(O,d,T,S,x,b),this.transform(R,d,Y,X,x,b);for(var ce=0;ce<x;ce++){var pe=T[ce]*Y[ce]-S[ce]*X[ce];S[ce]=T[ce]*X[ce]+S[ce]*Y[ce],T[ce]=pe}return this.conjugate(T,S,x),this.transform(T,S,ne,d,x,b),this.conjugate(ne,d,x),this.normalize13b(ne,x),_.negative=f.negative^p.negative,_.length=f.length+p.length,_._strip()},n.prototype.mul=function(f){var p=new n(null);return p.words=new Array(this.length+f.length),this.mulTo(f,p)},n.prototype.mulf=function(f){var p=new n(null);return p.words=new Array(this.length+f.length),K(this,f,p)},n.prototype.imul=function(f){return this.clone().mulTo(f,this)},n.prototype.imuln=function(f){var p=f<0;p&&(f=-f),r(typeof f=="number"),r(f<67108864);for(var _=0,x=0;x<this.length;x++){var b=(this.words[x]|0)*f,d=(b&67108863)+(_&67108863);_>>=26,_+=b/67108864|0,_+=d>>>26,this.words[x]=d&67108863}return _!==0&&(this.words[x]=_,this.length++),this.length=f===0?1:this.length,p?this.ineg():this},n.prototype.muln=function(f){return this.clone().imuln(f)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(f){var p=M(f);if(p.length===0)return new n(1);for(var _=this,x=0;x<p.length&&p[x]===0;x++,_=_.sqr());if(++x<p.length)for(var b=_.sqr();x<p.length;x++,b=b.sqr())p[x]!==0&&(_=_.mul(b));return _},n.prototype.iushln=function(f){r(typeof f=="number"&&f>=0);var p=f%26,_=(f-p)/26,x=67108863>>>26-p<<26-p,b;if(p!==0){var d=0;for(b=0;b<this.length;b++){var O=this.words[b]&x,T=(this.words[b]|0)-O<<p;this.words[b]=T|d,d=O>>>26-p}d&&(this.words[b]=d,this.length++)}if(_!==0){for(b=this.length-1;b>=0;b--)this.words[b+_]=this.words[b];for(b=0;b<_;b++)this.words[b]=0;this.length+=_}return this._strip()},n.prototype.ishln=function(f){return r(this.negative===0),this.iushln(f)},n.prototype.iushrn=function(f,p,_){r(typeof f=="number"&&f>=0);var x;p?x=(p-p%26)/26:x=0;var b=f%26,d=Math.min((f-b)/26,this.length),O=67108863^67108863>>>b<<b,T=_;if(x-=d,x=Math.max(0,x),T){for(var S=0;S<d;S++)T.words[S]=this.words[S];T.length=d}if(d!==0)if(this.length>d)for(this.length-=d,S=0;S<this.length;S++)this.words[S]=this.words[S+d];else this.words[0]=0,this.length=1;var R=0;for(S=this.length-1;S>=0&&(R!==0||S>=x);S--){var Y=this.words[S]|0;this.words[S]=R<<26-b|Y>>>b,R=Y&O}return T&&R!==0&&(T.words[T.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(f,p,_){return r(this.negative===0),this.iushrn(f,p,_)},n.prototype.shln=function(f){return this.clone().ishln(f)},n.prototype.ushln=function(f){return this.clone().iushln(f)},n.prototype.shrn=function(f){return this.clone().ishrn(f)},n.prototype.ushrn=function(f){return this.clone().iushrn(f)},n.prototype.testn=function(f){r(typeof f=="number"&&f>=0);var p=f%26,_=(f-p)/26,x=1<<p;if(this.length<=_)return!1;var b=this.words[_];return!!(b&x)},n.prototype.imaskn=function(f){r(typeof f=="number"&&f>=0);var p=f%26,_=(f-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=_)return this;if(p!==0&&_++,this.length=Math.min(_,this.length),p!==0){var x=67108863^67108863>>>p<<p;this.words[this.length-1]&=x}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.maskn=function(f){return this.clone().imaskn(f)},n.prototype.iaddn=function(f){return r(typeof f=="number"),r(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},n.prototype._iaddn=function(f){this.words[0]+=f;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},n.prototype.isubn=function(f){if(r(typeof f=="number"),r(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},n.prototype.addn=function(f){return this.clone().iaddn(f)},n.prototype.subn=function(f){return this.clone().isubn(f)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(f,p,_){var x=f.length+_,b;this._expand(x);var d,O=0;for(b=0;b<f.length;b++){d=(this.words[b+_]|0)+O;var T=(f.words[b]|0)*p;d-=T&67108863,O=(d>>26)-(T/67108864|0),this.words[b+_]=d&67108863}for(;b<this.length-_;b++)d=(this.words[b+_]|0)+O,O=d>>26,this.words[b+_]=d&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,b=0;b<this.length;b++)d=-(this.words[b]|0)+O,O=d>>26,this.words[b]=d&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(f,p){var _=this.length-f.length,x=this.clone(),b=f,d=b.words[b.length-1]|0,O=this._countBits(d);_=26-O,_!==0&&(b=b.ushln(_),x.iushln(_),d=b.words[b.length-1]|0);var T=x.length-b.length,S;if(p!=="mod"){S=new n(null),S.length=T+1,S.words=new Array(S.length);for(var R=0;R<S.length;R++)S.words[R]=0}var Y=x.clone()._ishlnsubmul(b,1,T);Y.negative===0&&(x=Y,S&&(S.words[T]=1));for(var X=T-1;X>=0;X--){var ne=(x.words[b.length+X]|0)*67108864+(x.words[b.length+X-1]|0);for(ne=Math.min(ne/d|0,67108863),x._ishlnsubmul(b,ne,X);x.negative!==0;)ne--,x.negative=0,x._ishlnsubmul(b,1,X),x.isZero()||(x.negative^=1);S&&(S.words[X]=ne)}return S&&S._strip(),x._strip(),p!=="div"&&_!==0&&x.iushrn(_),{div:S||null,mod:x}},n.prototype.divmod=function(f,p,_){if(r(!f.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,b,d;return this.negative!==0&&f.negative===0?(d=this.neg().divmod(f,p),p!=="mod"&&(x=d.div.neg()),p!=="div"&&(b=d.mod.neg(),_&&b.negative!==0&&b.iadd(f)),{div:x,mod:b}):this.negative===0&&f.negative!==0?(d=this.divmod(f.neg(),p),p!=="mod"&&(x=d.div.neg()),{div:x,mod:d.mod}):(this.negative&f.negative)!==0?(d=this.neg().divmod(f.neg(),p),p!=="div"&&(b=d.mod.neg(),_&&b.negative!==0&&b.isub(f)),{div:d.div,mod:b}):f.length>this.length||this.cmp(f)<0?{div:new n(0),mod:this}:f.length===1?p==="div"?{div:this.divn(f.words[0]),mod:null}:p==="mod"?{div:null,mod:new n(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new n(this.modrn(f.words[0]))}:this._wordDiv(f,p)},n.prototype.div=function(f){return this.divmod(f,"div",!1).div},n.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},n.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},n.prototype.divRound=function(f){var p=this.divmod(f);if(p.mod.isZero())return p.div;var _=p.div.negative!==0?p.mod.isub(f):p.mod,x=f.ushrn(1),b=f.andln(1),d=_.cmp(x);return d<0||b===1&&d===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},n.prototype.modrn=function(f){var p=f<0;p&&(f=-f),r(f<=67108863);for(var _=(1<<26)%f,x=0,b=this.length-1;b>=0;b--)x=(_*x+(this.words[b]|0))%f;return p?-x:x},n.prototype.modn=function(f){return this.modrn(f)},n.prototype.idivn=function(f){var p=f<0;p&&(f=-f),r(f<=67108863);for(var _=0,x=this.length-1;x>=0;x--){var b=(this.words[x]|0)+_*67108864;this.words[x]=b/f|0,_=b%f}return this._strip(),p?this.ineg():this},n.prototype.divn=function(f){return this.clone().idivn(f)},n.prototype.egcd=function(f){r(f.negative===0),r(!f.isZero());var p=this,_=f.clone();p.negative!==0?p=p.umod(f):p=p.clone();for(var x=new n(1),b=new n(0),d=new n(0),O=new n(1),T=0;p.isEven()&&_.isEven();)p.iushrn(1),_.iushrn(1),++T;for(var S=_.clone(),R=p.clone();!p.isZero();){for(var Y=0,X=1;(p.words[0]&X)===0&&Y<26;++Y,X<<=1);if(Y>0)for(p.iushrn(Y);Y-- >0;)(x.isOdd()||b.isOdd())&&(x.iadd(S),b.isub(R)),x.iushrn(1),b.iushrn(1);for(var ne=0,ce=1;(_.words[0]&ce)===0&&ne<26;++ne,ce<<=1);if(ne>0)for(_.iushrn(ne);ne-- >0;)(d.isOdd()||O.isOdd())&&(d.iadd(S),O.isub(R)),d.iushrn(1),O.iushrn(1);p.cmp(_)>=0?(p.isub(_),x.isub(d),b.isub(O)):(_.isub(p),d.isub(x),O.isub(b))}return{a:d,b:O,gcd:_.iushln(T)}},n.prototype._invmp=function(f){r(f.negative===0),r(!f.isZero());var p=this,_=f.clone();p.negative!==0?p=p.umod(f):p=p.clone();for(var x=new n(1),b=new n(0),d=_.clone();p.cmpn(1)>0&&_.cmpn(1)>0;){for(var O=0,T=1;(p.words[0]&T)===0&&O<26;++O,T<<=1);if(O>0)for(p.iushrn(O);O-- >0;)x.isOdd()&&x.iadd(d),x.iushrn(1);for(var S=0,R=1;(_.words[0]&R)===0&&S<26;++S,R<<=1);if(S>0)for(_.iushrn(S);S-- >0;)b.isOdd()&&b.iadd(d),b.iushrn(1);p.cmp(_)>=0?(p.isub(_),x.isub(b)):(_.isub(p),b.isub(x))}var Y;return p.cmpn(1)===0?Y=x:Y=b,Y.cmpn(0)<0&&Y.iadd(f),Y},n.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var p=this.clone(),_=f.clone();p.negative=0,_.negative=0;for(var x=0;p.isEven()&&_.isEven();x++)p.iushrn(1),_.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;_.isEven();)_.iushrn(1);var b=p.cmp(_);if(b<0){var d=p;p=_,_=d}else if(b===0||_.cmpn(1)===0)break;p.isub(_)}while(!0);return _.iushln(x)},n.prototype.invm=function(f){return this.egcd(f).a.umod(f)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(f){return this.words[0]&f},n.prototype.bincn=function(f){r(typeof f=="number");var p=f%26,_=(f-p)/26,x=1<<p;if(this.length<=_)return this._expand(_+1),this.words[_]|=x,this;for(var b=x,d=_;b!==0&&d<this.length;d++){var O=this.words[d]|0;O+=b,b=O>>>26,O&=67108863,this.words[d]=O}return b!==0&&(this.words[d]=b,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(f){var p=f<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var _;if(this.length>1)_=1;else{p&&(f=-f),r(f<=67108863,"Number is too big");var x=this.words[0]|0;_=x===f?0:x<f?-1:1}return this.negative!==0?-_|0:_},n.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var p=this.ucmp(f);return this.negative!==0?-p|0:p},n.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var p=0,_=this.length-1;_>=0;_--){var x=this.words[_]|0,b=f.words[_]|0;if(x!==b){x<b?p=-1:x>b&&(p=1);break}}return p},n.prototype.gtn=function(f){return this.cmpn(f)===1},n.prototype.gt=function(f){return this.cmp(f)===1},n.prototype.gten=function(f){return this.cmpn(f)>=0},n.prototype.gte=function(f){return this.cmp(f)>=0},n.prototype.ltn=function(f){return this.cmpn(f)===-1},n.prototype.lt=function(f){return this.cmp(f)===-1},n.prototype.lten=function(f){return this.cmpn(f)<=0},n.prototype.lte=function(f){return this.cmp(f)<=0},n.prototype.eqn=function(f){return this.cmpn(f)===0},n.prototype.eq=function(f){return this.cmp(f)===0},n.red=function(f){return new g(f)},n.prototype.toRed=function(f){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(f){return this.red=f,this},n.prototype.forceRed=function(f){return r(!this.red,"Already a number in reduction context"),this._forceRed(f)},n.prototype.redAdd=function(f){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},n.prototype.redIAdd=function(f){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},n.prototype.redSub=function(f){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},n.prototype.redISub=function(f){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},n.prototype.redShl=function(f){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},n.prototype.redMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},n.prototype.redIMul=function(f){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(f){return r(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var N={k256:null,p224:null,p192:null,p25519:null};function F(y,f){this.name=y,this.p=new n(f,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var f=new n(null);return f.words=new Array(Math.ceil(this.n/13)),f},F.prototype.ireduce=function(f){var p=f,_;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),_=p.bitLength();while(_>this.n);var x=_<this.n?-1:p.ucmp(this.p);return x===0?(p.words[0]=0,p.length=1):x>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},F.prototype.split=function(f,p){f.iushrn(this.n,0,p)},F.prototype.imulK=function(f){return f.imul(this.k)};function H(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(H,F),H.prototype.split=function(f,p){for(var _=4194303,x=Math.min(f.length,9),b=0;b<x;b++)p.words[b]=f.words[b];if(p.length=x,f.length<=9){f.words[0]=0,f.length=1;return}var d=f.words[9];for(p.words[p.length++]=d&_,b=10;b<f.length;b++){var O=f.words[b]|0;f.words[b-10]=(O&_)<<4|d>>>22,d=O}d>>>=22,f.words[b-10]=d,d===0&&f.length>10?f.length-=10:f.length-=9},H.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var p=0,_=0;_<f.length;_++){var x=f.words[_]|0;p+=x*977,f.words[_]=p&67108863,p=x*64+(p/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(z,F);function V(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(V,F);function B(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(B,F),B.prototype.imulK=function(f){for(var p=0,_=0;_<f.length;_++){var x=(f.words[_]|0)*19+p,b=x&67108863;x>>>=26,f.words[_]=b,p=x}return p!==0&&(f.words[f.length++]=p),f},n._prime=function(f){if(N[f])return N[f];var p;if(f==="k256")p=new H;else if(f==="p224")p=new z;else if(f==="p192")p=new V;else if(f==="p25519")p=new B;else throw new Error("Unknown prime "+f);return N[f]=p,p};function g(y){if(typeof y=="string"){var f=n._prime(y);this.m=f.p,this.prime=f}else r(y.gtn(1),"modulus must be greater than 1"),this.m=y,this.prime=null}g.prototype._verify1=function(f){r(f.negative===0,"red works only with positives"),r(f.red,"red works only with red numbers")},g.prototype._verify2=function(f,p){r((f.negative|p.negative)===0,"red works only with positives"),r(f.red&&f.red===p.red,"red works only with red numbers")},g.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(c(f,f.umod(this.m)._forceRed(this)),f)},g.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},g.prototype.add=function(f,p){this._verify2(f,p);var _=f.add(p);return _.cmp(this.m)>=0&&_.isub(this.m),_._forceRed(this)},g.prototype.iadd=function(f,p){this._verify2(f,p);var _=f.iadd(p);return _.cmp(this.m)>=0&&_.isub(this.m),_},g.prototype.sub=function(f,p){this._verify2(f,p);var _=f.sub(p);return _.cmpn(0)<0&&_.iadd(this.m),_._forceRed(this)},g.prototype.isub=function(f,p){this._verify2(f,p);var _=f.isub(p);return _.cmpn(0)<0&&_.iadd(this.m),_},g.prototype.shl=function(f,p){return this._verify1(f),this.imod(f.ushln(p))},g.prototype.imul=function(f,p){return this._verify2(f,p),this.imod(f.imul(p))},g.prototype.mul=function(f,p){return this._verify2(f,p),this.imod(f.mul(p))},g.prototype.isqr=function(f){return this.imul(f,f.clone())},g.prototype.sqr=function(f){return this.mul(f,f)},g.prototype.sqrt=function(f){if(f.isZero())return f.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var _=this.m.add(new n(1)).iushrn(2);return this.pow(f,_)}for(var x=this.m.subn(1),b=0;!x.isZero()&&x.andln(1)===0;)b++,x.iushrn(1);r(!x.isZero());var d=new n(1).toRed(this),O=d.redNeg(),T=this.m.subn(1).iushrn(1),S=this.m.bitLength();for(S=new n(2*S*S).toRed(this);this.pow(S,T).cmp(O)!==0;)S.redIAdd(O);for(var R=this.pow(S,x),Y=this.pow(f,x.addn(1).iushrn(1)),X=this.pow(f,x),ne=b;X.cmp(d)!==0;){for(var ce=X,pe=0;ce.cmp(d)!==0;pe++)ce=ce.redSqr();r(pe<ne);var q=this.pow(R,new n(1).iushln(ne-pe-1));Y=Y.redMul(q),R=q.redSqr(),X=X.redMul(R),ne=pe}return Y},g.prototype.invm=function(f){var p=f._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},g.prototype.pow=function(f,p){if(p.isZero())return new n(1).toRed(this);if(p.cmpn(1)===0)return f.clone();var _=4,x=new Array(1<<_);x[0]=new n(1).toRed(this),x[1]=f;for(var b=2;b<x.length;b++)x[b]=this.mul(x[b-1],f);var d=x[0],O=0,T=0,S=p.bitLength()%26;for(S===0&&(S=26),b=p.length-1;b>=0;b--){for(var R=p.words[b],Y=S-1;Y>=0;Y--){var X=R>>Y&1;if(d!==x[0]&&(d=this.sqr(d)),X===0&&O===0){T=0;continue}O<<=1,O|=X,T++,!(T!==_&&(b!==0||Y!==0))&&(d=this.mul(d,x[O]),T=0,O=0)}S=26}return d},g.prototype.convertTo=function(f){var p=f.umod(this.m);return p===f?p.clone():p},g.prototype.convertFrom=function(f){var p=f.clone();return p.red=null,p},n.mont=function(f){return new I(f)};function I(y){g.call(this,y),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(I,g),I.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},I.prototype.convertFrom=function(f){var p=this.imod(f.mul(this.rinv));return p.red=null,p},I.prototype.imul=function(f,p){if(f.isZero()||p.isZero())return f.words[0]=0,f.length=1,f;var _=f.imul(p),x=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=_.isub(x).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},I.prototype.mul=function(f,p){if(f.isZero()||p.isZero())return new n(0)._forceRed(this);var _=f.mul(p),x=_.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=_.isub(x).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},I.prototype.invm=function(f){var p=this.imod(f._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(typeof Bm>"u"||Bm,BI)});var Mm=k((T1e,DI)=>{"use strict";v();var Rc=MI(),jY=bu(),zY=ot().Buffer;function CI(e){var t=e.modulus.byteLength(),r;do r=new Rc(jY(t));while(r.cmp(e.modulus)>=0||!r.umod(e.prime1)||!r.umod(e.prime2));return r}function KY(e){var t=CI(e),r=t.toRed(Rc.mont(e.modulus)).redPow(new Rc(e.publicExponent)).fromRed();return{blinder:r,unblinder:t.invm(e.modulus)}}function NI(e,t){var r=KY(t),i=t.modulus.byteLength(),n=new Rc(e).mul(r.blinder).umod(t.modulus),o=n.toRed(Rc.mont(t.prime1)),a=n.toRed(Rc.mont(t.prime2)),s=t.coefficient,u=t.prime1,c=t.prime2,l=o.redPow(t.exponent1).fromRed(),m=a.redPow(t.exponent2).fromRed(),w=l.isub(m).imul(s).umod(u).imul(c);return m.iadd(w).imul(r.unblinder).umod(t.modulus).toArrayLike(zY,"be",i)}NI.getr=CI;DI.exports=NI});var FI=k((R1e,UI)=>{v();var VY=Am(),Cm=bu(),GY=Hh(),LI=Tm(),qI=km(),Nm=Cn(),ZY=Rm(),WY=Mm(),Un=ot().Buffer;UI.exports=function(t,r,i){var n;t.padding?n=t.padding:i?n=1:n=4;var o=VY(t),a;if(n===4)a=YY(o,r);else if(n===1)a=$Y(o,r,i);else if(n===3){if(a=new Nm(r),a.cmp(o.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return i?WY(a,o):ZY(a,o)};function YY(e,t){var r=e.modulus.byteLength(),i=t.length,n=GY("sha1").update(Un.alloc(0)).digest(),o=n.length,a=2*o;if(i>r-a-2)throw new Error("message too long");var s=Un.alloc(r-i-a-2),u=r-o-1,c=Cm(o),l=qI(Un.concat([n,s,Un.alloc(1,1),t],u),LI(c,u)),m=qI(c,LI(l,o));return new Nm(Un.concat([Un.alloc(1),m,l],r))}function $Y(e,t,r){var i=t.length,n=e.modulus.byteLength();if(i>n-11)throw new Error("message too long");var o;return r?o=Un.alloc(n-i-3,255):o=XY(n-i-3),new Nm(Un.concat([Un.from([0,r?1:2]),o,Un.alloc(1),t],n))}function XY(e){for(var t=Un.allocUnsafe(e),r=0,i=Cm(e*2),n=0,o;r<e;)n===i.length&&(i=Cm(e*2),n=0),o=i[n++],o&&(t[r++]=o);return t}});var VI=k((M1e,KI)=>{v();var JY=Am(),HI=Tm(),jI=km(),zI=Cn(),QY=Mm(),e$=Hh(),t$=Rm(),Qh=ot().Buffer;KI.exports=function(t,r,i){var n;t.padding?n=t.padding:i?n=1:n=4;var o=JY(t),a=o.modulus.byteLength();if(r.length>a||new zI(r).cmp(o.modulus)>=0)throw new Error("decryption error");var s;i?s=t$(new zI(r),o):s=QY(r,o);var u=Qh.alloc(a-s.length);if(s=Qh.concat([u,s],a),n===4)return r$(o,s);if(n===1)return i$(o,s,i);if(n===3)return s;throw new Error("unknown padding")};function r$(e,t){var r=e.modulus.byteLength(),i=e$("sha1").update(Qh.alloc(0)).digest(),n=i.length;if(t[0]!==0)throw new Error("decryption error");var o=t.slice(1,n+1),a=t.slice(n+1),s=jI(o,HI(a,n)),u=jI(a,HI(s,r-n-1));if(n$(i,u.slice(0,n)))throw new Error("decryption error");for(var c=n;u[c]===0;)c++;if(u[c++]!==1)throw new Error("decryption error");return u.slice(c)}function i$(e,t,r){for(var i=t.slice(0,2),n=2,o=0;t[n++]!==0;)if(n>=t.length){o++;break}var a=t.slice(2,n-1);if((i.toString("hex")!=="0002"&&!r||i.toString("hex")!=="0001"&&r)&&o++,a.length<8&&o++,o)throw new Error("decryption error");return t.slice(n)}function n$(e,t){e=Qh.from(e),t=Qh.from(t);var r=0,i=e.length;e.length!==t.length&&(r++,i=Math.min(e.length,t.length));for(var n=-1;++n<i;)r+=e[n]^t[n];return r}});var GI=k(Ku=>{v();Ku.publicEncrypt=FI();Ku.privateDecrypt=VI();Ku.privateEncrypt=function(t,r){return Ku.publicEncrypt(t,r,!0)};Ku.publicDecrypt=function(t,r){return Ku.privateDecrypt(t,r,!0)}});var rO=k(e0=>{"use strict";v();function ZI(){throw new Error(`secure random number generation not supported by this browser
15
15
  use chrome, FireFox or Internet Explorer 11`)}var YI=ot(),WI=bu(),$I=YI.Buffer,XI=YI.kMaxLength,Dm=globalThis.crypto||globalThis.msCrypto,JI=Math.pow(2,32)-1;function QI(e,t){if(typeof e!="number"||e!==e)throw new TypeError("offset must be a number");if(e>JI||e<0)throw new TypeError("offset must be a uint32");if(e>XI||e>t)throw new RangeError("offset out of range")}function eO(e,t,r){if(typeof e!="number"||e!==e)throw new TypeError("size must be a number");if(e>JI||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>XI)throw new RangeError("buffer too small")}Dm&&Dm.getRandomValues||!A.default.browser?(e0.randomFill=o$,e0.randomFillSync=a$):(e0.randomFill=ZI,e0.randomFillSync=ZI);function o$(e,t,r,i){if(!$I.isBuffer(e)&&!(e instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof t=="function")i=t,t=0,r=e.length;else if(typeof r=="function")i=r,r=e.length-t;else if(typeof i!="function")throw new TypeError('"cb" argument must be a function');return QI(t,e.length),eO(r,t,e.length),tO(e,t,r,i)}function tO(e,t,r,i){if(A.default.browser){var n=e.buffer,o=new Uint8Array(n,t,r);if(Dm.getRandomValues(o),i){A.default.nextTick(function(){i(null,e)});return}return e}if(i){WI(r,function(s,u){if(s)return i(s);u.copy(e,t),i(null,e)});return}var a=WI(r);return a.copy(e,t),e}function a$(e,t,r){if(typeof t>"u"&&(t=0),!$I.isBuffer(e)&&!(e instanceof globalThis.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return QI(t,e.length),r===void 0&&(r=e.length-t),eO(r,t,e.length),tO(e,t,r)}});var _r=k(at=>{"use strict";v();at.randomBytes=at.rng=at.pseudoRandomBytes=at.prng=bu();at.createHash=at.Hash=Hh();at.createHmac=at.Hmac=JS();var s$=fs(),u$=Object.keys(s$),f$=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(u$);at.getHashes=function(){return f$};var iO=Dv();at.pbkdf2=iO.pbkdf2;at.pbkdf2Sync=iO.pbkdf2Sync;var Eo=xE();at.Cipher=Eo.Cipher;at.createCipher=Eo.createCipher;at.Cipheriv=Eo.Cipheriv;at.createCipheriv=Eo.createCipheriv;at.Decipher=Eo.Decipher;at.createDecipher=Eo.createDecipher;at.Decipheriv=Eo.Decipheriv;at.createDecipheriv=Eo.createDecipheriv;at.getCiphers=Eo.getCiphers;at.listCiphers=Eo.listCiphers;var t0=LE();at.DiffieHellmanGroup=t0.DiffieHellmanGroup;at.createDiffieHellmanGroup=t0.createDiffieHellmanGroup;at.getDiffieHellman=t0.getDiffieHellman;at.createDiffieHellman=t0.createDiffieHellman;at.DiffieHellman=t0.DiffieHellman;var K2=fs();at.createSign=K2.createSign;at.Sign=K2.Sign;at.createVerify=K2.createVerify;at.Verify=K2.Verify;at.createECDH=fs();var V2=GI();at.publicEncrypt=V2.publicEncrypt;at.privateEncrypt=V2.privateEncrypt;at.publicDecrypt=V2.publicDecrypt;at.privateDecrypt=V2.privateDecrypt;var nO=rO();at.randomFill=nO.randomFill;at.randomFillSync=nO.randomFillSync;at.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
16
16
  we accept pull requests
17
- https://github.com/browserify/crypto-browserify`)};at.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var ds=k((H1e,oO)=>{"use strict";v();function Bc(){}Bc.getRandomBuffer=function(e){return A.default.browser?Bc.getRandomBufferBrowser(e):Bc.getRandomBufferNode(e)};Bc.getRandomBufferNode=function(e){var t=_r();return t.randomBytes(e)};Bc.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)t=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(e);t.getRandomValues(r);var i=h.Buffer.from(r);return i};oO.exports=Bc});var Et=k((z1e,aO)=>{"use strict";v();var c$=ds(),Vt={};Vt.isArray=e=>Array.isArray(e);Vt.isNumber=e=>typeof e=="number";Vt.isObject=e=>e&&typeof e=="object";Vt.isString=e=>typeof e=="string";Vt.isUndefined=e=>typeof e>"u";Vt.isFunction=e=>typeof e=="function";Vt.isNull=e=>e===null;Vt.isDate=e=>e instanceof Date;Vt.extend=(e,t)=>Object.assign(e,t);Vt.noop=()=>{};Vt.every=(e,t)=>e.every(t||(r=>r));Vt.map=(e,t)=>Array.from(e).map(t||(r=>r));Vt.includes=(e,t)=>e.includes(t);Vt.each=(e,t)=>e.forEach(t);Vt.clone=e=>Object.assign({},e);Vt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};Vt.values=e=>Object.values(e);Vt.filter=(e,t)=>e.filter(t);Vt.reduce=(e,t,r)=>e.reduce(t,r);Vt.without=(e,t)=>e.filter(r=>r!==t);Vt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=c$.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Vt.difference=(e,t)=>e.filter(r=>!t.includes(r));Vt.findIndex=(e,t)=>e.findIndex(t);Vt.some=(e,t)=>e.some(t);Vt.range=e=>[...Array(e).keys()];aO.exports=Vt});var uO=k((V1e,sO)=>{"use strict";v();var G2=ot().Buffer;function l$(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var n=e.charAt(i),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=i}var a=e.length,s=e.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(E){if((Array.isArray(E)||E instanceof Uint8Array)&&(E=G2.from(E)),!G2.isBuffer(E))throw new TypeError("Expected Buffer");if(E.length===0)return"";for(var P=0,M=0,D=0,L=E.length;D!==L&&E[D]===0;)D++,P++;for(var U=(L-D)*c+1>>>0,K=new Uint8Array(U);D!==L;){for(var C=E[D],N=0,F=U-1;(C!==0||N<M)&&F!==-1;F--,N++)C+=256*K[F]>>>0,K[F]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");M=N,D++}for(var H=U-M;H!==U&&K[H]===0;)H++;for(var z=s.repeat(P);H<U;++H)z+=e.charAt(K[H]);return z}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return G2.alloc(0);for(var P=0,M=0,D=0;E[P]===s;)M++,P++;for(var L=(E.length-P)*u+1>>>0,U=new Uint8Array(L);P<E.length;){var K=E.charCodeAt(P);if(K>255)return;var C=t[K];if(C===255)return;for(var N=0,F=L-1;(C!==0||N<D)&&F!==-1;F--,N++)C+=a*U[F]>>>0,U[F]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");D=N,P++}for(var H=L-D;H!==L&&U[H]===0;)H++;var z=G2.allocUnsafe(M+(L-H));z.fill(0,0,M);for(var V=M;H!==L;)z[V++]=U[H++];return z}function w(E){var P=m(E);if(P)return P;throw new Error("Non-base"+a+" character")}return{encode:l,decodeUnsafe:m,decode:w}}sO.exports=l$});var Z2=k((Z1e,fO)=>{v();var h$=uO(),d$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";fO.exports=h$(d$)});var Lm=k((Y1e,cO)=>{"use strict";v();cO.exports="7.6.1"});var hO=k((X1e,lO)=>{"use strict";v();var p$="https://docs.moneybutton.com/";lO.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+p$+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var hn=k((Q1e,Um)=>{"use strict";v();var qm=Et();function g$(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var dO=function(e,t){var r=function(){if(qm.isString(t.message))this.message=g$(t.message,arguments);else if(qm.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
17
+ https://github.com/browserify/crypto-browserify`)};at.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var ds=k((H1e,oO)=>{"use strict";v();function Bc(){}Bc.getRandomBuffer=function(e){return A.default.browser?Bc.getRandomBufferBrowser(e):Bc.getRandomBufferNode(e)};Bc.getRandomBufferNode=function(e){var t=_r();return t.randomBytes(e)};Bc.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else if(window.msCrypto&&window.msCrypto.getRandomValues)t=window.msCrypto;else throw new Error("window.crypto.getRandomValues not available");var r=new Uint8Array(e);t.getRandomValues(r);var i=h.Buffer.from(r);return i};oO.exports=Bc});var Et=k((z1e,aO)=>{"use strict";v();var c$=ds(),Vt={};Vt.isArray=e=>Array.isArray(e);Vt.isNumber=e=>typeof e=="number";Vt.isObject=e=>e&&typeof e=="object";Vt.isString=e=>typeof e=="string";Vt.isUndefined=e=>typeof e>"u";Vt.isFunction=e=>typeof e=="function";Vt.isNull=e=>e===null;Vt.isDate=e=>e instanceof Date;Vt.extend=(e,t)=>Object.assign(e,t);Vt.noop=()=>{};Vt.every=(e,t)=>e.every(t||(r=>r));Vt.map=(e,t)=>Array.from(e).map(t||(r=>r));Vt.includes=(e,t)=>e.includes(t);Vt.each=(e,t)=>e.forEach(t);Vt.clone=e=>Object.assign({},e);Vt.pick=(e,t)=>{let r={};return t.forEach(i=>{typeof e[i]<"u"&&(r[i]=e[i])}),r};Vt.values=e=>Object.values(e);Vt.filter=(e,t)=>e.filter(t);Vt.reduce=(e,t,r)=>e.reduce(t,r);Vt.without=(e,t)=>e.filter(r=>r!==t);Vt.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let n=c$.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(n*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Vt.difference=(e,t)=>e.filter(r=>!t.includes(r));Vt.findIndex=(e,t)=>e.findIndex(t);Vt.some=(e,t)=>e.some(t);Vt.range=e=>[...Array(e).keys()];aO.exports=Vt});var uO=k((V1e,sO)=>{"use strict";v();var G2=ot().Buffer;function l$(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var n=e.charAt(i),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=i}var a=e.length,s=e.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(E){if((Array.isArray(E)||E instanceof Uint8Array)&&(E=G2.from(E)),!G2.isBuffer(E))throw new TypeError("Expected Buffer");if(E.length===0)return"";for(var P=0,M=0,D=0,L=E.length;D!==L&&E[D]===0;)D++,P++;for(var U=(L-D)*c+1>>>0,K=new Uint8Array(U);D!==L;){for(var C=E[D],N=0,F=U-1;(C!==0||N<M)&&F!==-1;F--,N++)C+=256*K[F]>>>0,K[F]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");M=N,D++}for(var H=U-M;H!==U&&K[H]===0;)H++;for(var z=s.repeat(P);H<U;++H)z+=e.charAt(K[H]);return z}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return G2.alloc(0);for(var P=0,M=0,D=0;E[P]===s;)M++,P++;for(var L=(E.length-P)*u+1>>>0,U=new Uint8Array(L);P<E.length;){var K=E.charCodeAt(P);if(K>255)return;var C=t[K];if(C===255)return;for(var N=0,F=L-1;(C!==0||N<D)&&F!==-1;F--,N++)C+=a*U[F]>>>0,U[F]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");D=N,P++}for(var H=L-D;H!==L&&U[H]===0;)H++;var z=G2.allocUnsafe(M+(L-H));z.fill(0,0,M);for(var V=M;H!==L;)z[V++]=U[H++];return z}function w(E){var P=m(E);if(P)return P;throw new Error("Non-base"+a+" character")}return{encode:l,decodeUnsafe:m,decode:w}}sO.exports=l$});var Z2=k((Z1e,fO)=>{v();var h$=uO(),d$="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";fO.exports=h$(d$)});var Lm=k((Y1e,cO)=>{"use strict";v();cO.exports="7.6.2"});var hO=k((X1e,lO)=>{"use strict";v();var p$="https://docs.moneybutton.com/";lO.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+p$+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var hn=k((Q1e,Um)=>{"use strict";v();var qm=Et();function g$(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var dO=function(e,t){var r=function(){if(qm.isString(t.message))this.message=g$(t.message,arguments);else if(qm.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
18
18
  `+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&pO(r,t.errors),r},pO=function(e,t){qm.each(t,function(r){dO(e,r)})},v$=function(e,t){return pO(e,t),e},Mc={};Mc.Error=function(){this.message="Internal error",this.stack=this.message+`
19
19
  `+new Error().stack};Mc.Error.prototype=Object.create(Error.prototype);Mc.Error.prototype.name="bsv.Error";var m$=hO();v$(Mc.Error,m$);Um.exports=Mc.Error;Um.exports.extend=function(e){return dO(Mc.Error,e)}});var Bt=k((tde,gO)=>{"use strict";v();var r0=hn(),y$=Et();gO.exports={checkState:function(e,t){if(!e)throw new r0.InvalidState(t)},checkArgument:function(e,t,r,i){if(!e)throw new r0.InvalidArgument(t,r,i)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",y$.isString(t)){if(t==="Buffer"){var i=Kt();if(!i.Buffer.isBuffer(e))throw new r0.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new r0.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new r0.InvalidArgumentType(e,t.name,r)}}});var fr=k((ide,mO)=>{"use strict";v();var Ot=Cn(),Fm=Bt(),vO=Et(),W2=function(e){for(var t=h.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Ot.Zero=new Ot(0);Ot.One=new Ot(1);Ot.Minus1=new Ot(-1);Ot.fromNumber=function(e){return Fm.checkArgument(vO.isNumber(e)),new Ot(e)};Ot.fromString=function(e,t){return Fm.checkArgument(vO.isString(e)),new Ot(e,t)};Ot.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=W2(e));var r=e.toString("hex"),i=new Ot(r,16);return i};Ot.fromSM=function(e,t){var r;if(e.length===0)return Ot.fromBuffer(h.Buffer.from([0]));var i="big";return t&&(i=t.endian),i==="little"&&(e=W2(e)),e[0]&128?(e[0]=e[0]&127,r=Ot.fromBuffer(e),r.neg().copy(r)):r=Ot.fromBuffer(e),r};Ot.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Ot.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var i=r.length/2;t=h.Buffer.from(r,"hex"),i===e.size||(i>e.size?t=Ot.trim(t,i):i<e.size&&(t=Ot.pad(t,i,e.size)))}else r=this.toString(16,2),t=h.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=W2(t)),t};Ot.prototype.toSMBigEndian=function(){var e;return this.cmp(Ot.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=h.Buffer.concat([h.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=h.Buffer.concat([h.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=h.Buffer.from([])),e};Ot.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=W2(r)),r};Ot.fromScriptNumBuffer=function(e,t,r){var i=r||4;if(Fm.checkArgument(e.length<=i,new Error("script number overflow")),t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw new Error("non-minimally encoded script number");return Ot.fromSM(e,{endian:"little"})};Ot.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Ot.trim=function(e,t){return e.slice(t-e.length,e.length)};Ot.pad=function(e,t,r){for(var i=h.Buffer.alloc(r),n=0;n<e.length;n++)i[i.length-1-n]=e[e.length-1-n];for(n=0;n<r-t;n++)i[n]=0;return i};Ot.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Ot.fromHex=function(e,...t){return Ot.fromBuffer(h.Buffer.from(e,"hex"),...t)};mO.exports=Ot});function Hm(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ps(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function Io(e,t,r=""){let i=Hm(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let a=r&&`"${r}" `,s=o?` of length ${t}`:"",u=i?`length=${n}`:`type=${typeof e}`,c=a+"expected Uint8Array"+s+", got "+u;throw i?new RangeError(c):new TypeError(c)}return e}function Y2(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ps(e.outputLen),ps(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Cc(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $2(e,t){Io(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Ea(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function X2(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fn(e,t){return e<<32-t|e>>>t}function J2(e){if(Io(e),bO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=b$[e[r]];return t}function yO(e){if(e>=xa._0&&e<=xa._9)return e-xa._0;if(e>=xa.A&&e<=xa.F)return e-(xa.A-10);if(e>=xa.a&&e<=xa.f)return e-(xa.a-10)}function jm(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(bO)try{return Uint8Array.fromHex(e)}catch(n){throw n instanceof SyntaxError?new RangeError(n.message):n}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let a=yO(e.charCodeAt(o)),s=yO(e.charCodeAt(o+1));if(a===void 0||s===void 0){let u=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+u+'" at index '+o)}i[n]=a*16+s}return i}function Ia(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function _O(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Io(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function Vu(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=n=>e(n),Object.assign(r,t),Object.freeze(r)}function i0(e=32){ps(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var bO,b$,xa,Gu,gs=Xr(()=>{v();bO=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",b$=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));xa={_0:48,_9:57,A:65,F:70,a:97,f:102};Gu=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function wO(e,t,r){return e&t^~e&r}function SO(e,t,r){return e&t^e&r^t&r}var n0,Oa,Aa,Qr,ei,xO=Xr(()=>{v();gs();n0=class{constructor(t,r,i,n){Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"padOffset");Z(this,"isLE");Z(this,"buffer");Z(this,"view");Z(this,"finished",!1);Z(this,"length",0);Z(this,"pos",0);Z(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=X2(this.buffer)}update(t){Cc(this),Io(t);let{view:r,buffer:i,blockLen:n}=this,o=t.length;for(let a=0;a<o;){let s=Math.min(n-this.pos,o-a);if(s===n){let u=X2(t);for(;n<=o-a;a+=n)this.process(u,a);continue}i.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Cc(this),$2(t,this),this.finished=!0;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:a}=this;r[a++]=128,Ea(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(i,0),a=0);for(let m=a;m<n;m++)r[m]=0;i.setBigUint64(n-8,BigInt(this.length*8),o),this.process(i,0);let s=X2(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let c=u/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<c;m++)s.setUint32(4*m,l[m],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let i=t.slice(0,r);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:i,length:n,finished:o,destroyed:a,pos:s}=this;return t.destroyed=a,t.finished=o,t.length=n,t.pos=s,n%r&&t.buffer.set(i),t}clone(){return this._cloneInto()}},Oa=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Aa=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Qr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ei=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function _$(e,t=!1){return t?{h:Number(e&Q2),l:Number(e>>EO&Q2)}:{h:Number(e>>EO&Q2)|0,l:Number(e&Q2)|0}}function IO(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:a,l:s}=_$(e[o],t);[i[o],n[o]]=[a,s]}return[i,n]}function Oo(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Q2,EO,zm,Km,Zu,Wu,o0,a0,OO,AO,PO,TO,kO,RO,BO=Xr(()=>{v();Q2=BigInt(4294967295),EO=BigInt(32);zm=(e,t,r)=>e>>>r,Km=(e,t,r)=>e<<32-r|t>>>r,Zu=(e,t,r)=>e>>>r|t<<32-r,Wu=(e,t,r)=>e<<32-r|t>>>r,o0=(e,t,r)=>e<<64-r|t>>>r-32,a0=(e,t,r)=>e>>>r-32|t<<64-r;OO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),AO=(e,t,r,i)=>t+r+i+(e/2**32|0)|0,PO=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),TO=(e,t,r,i,n)=>t+r+i+n+(e/2**32|0)|0,kO=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),RO=(e,t,r,i,n,o)=>t+r+i+n+o+(e/2**32|0)|0});var Vm={};X1(Vm,{_SHA224:()=>rp,_SHA256:()=>tp,_SHA384:()=>np,_SHA512:()=>ip,_SHA512_224:()=>op,_SHA512_256:()=>ap,sha224:()=>I$,sha256:()=>bs,sha384:()=>A$,sha512:()=>O$,sha512_224:()=>T$,sha512_256:()=>P$});var S$,vs,ep,tp,rp,MO,x$,E$,ms,ys,Nc,ip,np,hi,di,op,ap,bs,I$,O$,A$,P$,T$,sp=Xr(()=>{v();xO();BO();gs();S$=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vs=new Uint32Array(64),ep=class extends n0{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:i,D:n,E:o,F:a,G:s,H:u}=this;return[t,r,i,n,o,a,s,u]}set(t,r,i,n,o,a,s,u){this.A=t|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=o|0,this.F=a|0,this.G=s|0,this.H=u|0}process(t,r){for(let m=0;m<16;m++,r+=4)vs[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let w=vs[m-15],E=vs[m-2],P=Fn(w,7)^Fn(w,18)^w>>>3,M=Fn(E,17)^Fn(E,19)^E>>>10;vs[m]=M+vs[m-7]+P+vs[m-16]|0}let{A:i,B:n,C:o,D:a,E:s,F:u,G:c,H:l}=this;for(let m=0;m<64;m++){let w=Fn(s,6)^Fn(s,11)^Fn(s,25),E=l+w+wO(s,u,c)+S$[m]+vs[m]|0,M=(Fn(i,2)^Fn(i,13)^Fn(i,22))+SO(i,n,o)|0;l=c,c=u,u=s,s=a+E|0,a=o,o=n,n=i,i=E+M|0}i=i+this.A|0,n=n+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,u=u+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(i,n,o,a,s,u,c,l)}roundClean(){Ea(vs)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ea(this.buffer)}},tp=class extends ep{constructor(){super(32);Z(this,"A",Oa[0]|0);Z(this,"B",Oa[1]|0);Z(this,"C",Oa[2]|0);Z(this,"D",Oa[3]|0);Z(this,"E",Oa[4]|0);Z(this,"F",Oa[5]|0);Z(this,"G",Oa[6]|0);Z(this,"H",Oa[7]|0)}},rp=class extends ep{constructor(){super(28);Z(this,"A",Aa[0]|0);Z(this,"B",Aa[1]|0);Z(this,"C",Aa[2]|0);Z(this,"D",Aa[3]|0);Z(this,"E",Aa[4]|0);Z(this,"F",Aa[5]|0);Z(this,"G",Aa[6]|0);Z(this,"H",Aa[7]|0)}},MO=IO(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),x$=MO[0],E$=MO[1],ms=new Uint32Array(80),ys=new Uint32Array(80),Nc=class extends n0{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:i,Bl:n,Ch:o,Cl:a,Dh:s,Dl:u,Eh:c,El:l,Fh:m,Fl:w,Gh:E,Gl:P,Hh:M,Hl:D}=this;return[t,r,i,n,o,a,s,u,c,l,m,w,E,P,M,D]}set(t,r,i,n,o,a,s,u,c,l,m,w,E,P,M,D){this.Ah=t|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=o|0,this.Cl=a|0,this.Dh=s|0,this.Dl=u|0,this.Eh=c|0,this.El=l|0,this.Fh=m|0,this.Fl=w|0,this.Gh=E|0,this.Gl=P|0,this.Hh=M|0,this.Hl=D|0}process(t,r){for(let K=0;K<16;K++,r+=4)ms[K]=t.getUint32(r),ys[K]=t.getUint32(r+=4);for(let K=16;K<80;K++){let C=ms[K-15]|0,N=ys[K-15]|0,F=Zu(C,N,1)^Zu(C,N,8)^zm(C,N,7),H=Wu(C,N,1)^Wu(C,N,8)^Km(C,N,7),z=ms[K-2]|0,V=ys[K-2]|0,B=Zu(z,V,19)^o0(z,V,61)^zm(z,V,6),g=Wu(z,V,19)^a0(z,V,61)^Km(z,V,6),I=PO(H,g,ys[K-7],ys[K-16]),y=TO(I,F,B,ms[K-7],ms[K-16]);ms[K]=y|0,ys[K]=I|0}let{Ah:i,Al:n,Bh:o,Bl:a,Ch:s,Cl:u,Dh:c,Dl:l,Eh:m,El:w,Fh:E,Fl:P,Gh:M,Gl:D,Hh:L,Hl:U}=this;for(let K=0;K<80;K++){let C=Zu(m,w,14)^Zu(m,w,18)^o0(m,w,41),N=Wu(m,w,14)^Wu(m,w,18)^a0(m,w,41),F=m&E^~m&M,H=w&P^~w&D,z=kO(U,N,H,E$[K],ys[K]),V=RO(z,L,C,F,x$[K],ms[K]),B=z|0,g=Zu(i,n,28)^o0(i,n,34)^o0(i,n,39),I=Wu(i,n,28)^a0(i,n,34)^a0(i,n,39),y=i&o^i&s^o&s,f=n&a^n&u^a&u;L=M|0,U=D|0,M=E|0,D=P|0,E=m|0,P=w|0,{h:m,l:w}=Oo(c|0,l|0,V|0,B|0),c=s|0,l=u|0,s=o|0,u=a|0,o=i|0,a=n|0;let p=OO(B,I,f);i=AO(p,V,g,y),n=p|0}({h:i,l:n}=Oo(this.Ah|0,this.Al|0,i|0,n|0)),{h:o,l:a}=Oo(this.Bh|0,this.Bl|0,o|0,a|0),{h:s,l:u}=Oo(this.Ch|0,this.Cl|0,s|0,u|0),{h:c,l}=Oo(this.Dh|0,this.Dl|0,c|0,l|0),{h:m,l:w}=Oo(this.Eh|0,this.El|0,m|0,w|0),{h:E,l:P}=Oo(this.Fh|0,this.Fl|0,E|0,P|0),{h:M,l:D}=Oo(this.Gh|0,this.Gl|0,M|0,D|0),{h:L,l:U}=Oo(this.Hh|0,this.Hl|0,L|0,U|0),this.set(i,n,o,a,s,u,c,l,m,w,E,P,M,D,L,U)}roundClean(){Ea(ms,ys)}destroy(){this.destroyed=!0,Ea(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ip=class extends Nc{constructor(){super(64);Z(this,"Ah",ei[0]|0);Z(this,"Al",ei[1]|0);Z(this,"Bh",ei[2]|0);Z(this,"Bl",ei[3]|0);Z(this,"Ch",ei[4]|0);Z(this,"Cl",ei[5]|0);Z(this,"Dh",ei[6]|0);Z(this,"Dl",ei[7]|0);Z(this,"Eh",ei[8]|0);Z(this,"El",ei[9]|0);Z(this,"Fh",ei[10]|0);Z(this,"Fl",ei[11]|0);Z(this,"Gh",ei[12]|0);Z(this,"Gl",ei[13]|0);Z(this,"Hh",ei[14]|0);Z(this,"Hl",ei[15]|0)}},np=class extends Nc{constructor(){super(48);Z(this,"Ah",Qr[0]|0);Z(this,"Al",Qr[1]|0);Z(this,"Bh",Qr[2]|0);Z(this,"Bl",Qr[3]|0);Z(this,"Ch",Qr[4]|0);Z(this,"Cl",Qr[5]|0);Z(this,"Dh",Qr[6]|0);Z(this,"Dl",Qr[7]|0);Z(this,"Eh",Qr[8]|0);Z(this,"El",Qr[9]|0);Z(this,"Fh",Qr[10]|0);Z(this,"Fl",Qr[11]|0);Z(this,"Gh",Qr[12]|0);Z(this,"Gl",Qr[13]|0);Z(this,"Hh",Qr[14]|0);Z(this,"Hl",Qr[15]|0)}},hi=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),di=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),op=class extends Nc{constructor(){super(28);Z(this,"Ah",hi[0]|0);Z(this,"Al",hi[1]|0);Z(this,"Bh",hi[2]|0);Z(this,"Bl",hi[3]|0);Z(this,"Ch",hi[4]|0);Z(this,"Cl",hi[5]|0);Z(this,"Dh",hi[6]|0);Z(this,"Dl",hi[7]|0);Z(this,"Eh",hi[8]|0);Z(this,"El",hi[9]|0);Z(this,"Fh",hi[10]|0);Z(this,"Fl",hi[11]|0);Z(this,"Gh",hi[12]|0);Z(this,"Gl",hi[13]|0);Z(this,"Hh",hi[14]|0);Z(this,"Hl",hi[15]|0)}},ap=class extends Nc{constructor(){super(32);Z(this,"Ah",di[0]|0);Z(this,"Al",di[1]|0);Z(this,"Bh",di[2]|0);Z(this,"Bl",di[3]|0);Z(this,"Ch",di[4]|0);Z(this,"Cl",di[5]|0);Z(this,"Dh",di[6]|0);Z(this,"Dl",di[7]|0);Z(this,"Eh",di[8]|0);Z(this,"El",di[9]|0);Z(this,"Fh",di[10]|0);Z(this,"Fl",di[11]|0);Z(this,"Gh",di[12]|0);Z(this,"Gl",di[13]|0);Z(this,"Hh",di[14]|0);Z(this,"Hl",di[15]|0)}},bs=Vu(()=>new tp,Gu(1)),I$=Vu(()=>new rp,Gu(4)),O$=Vu(()=>new ip,Gu(3)),A$=Vu(()=>new np,Gu(2)),P$=Vu(()=>new ap,Gu(6)),T$=Vu(()=>new op,Gu(5))});function $u(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function cp(e){if(typeof e=="bigint"){if(!up(e))throw new RangeError("positive bigint expected, got "+e)}else Zm(e);return e}function dn(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function s0(e){let t=cp(e).toString(16);return t.length&1?"0"+t:t}function CO(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?fp:BigInt("0x"+e)}function bi(e){return CO(J2(e))}function Lc(e){return CO(J2(hp(Io(e)).reverse()))}function lp(e,t){if(ps(t),t===0)throw new RangeError("zero length");e=cp(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return jm(r.padStart(t*2,"0"))}function Wm(e,t){return lp(e,t).reverse()}function hp(e){return Uint8Array.from(qt(e))}function qc(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}function k$(e,t,r){return up(e)&&up(t)&&up(r)&&t<=e&&e<r}function Ym(e,t,r,i){if(!k$(t,r,i))throw new RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Xu(e){if(e<fp)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>fp;e>>=Gm,t+=1);return t}function NO(e,t,r){if(ps(e,"hashLen"),ps(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let i=D=>new Uint8Array(D),n=Uint8Array.of(),o=Uint8Array.of(0),a=Uint8Array.of(1),s=1e3,u=i(e),c=i(e),l=0,m=()=>{u.fill(1),c.fill(0),l=0},w=(...D)=>r(c,kt(u,...D)),E=(D=n)=>{c=w(o,D),u=w(),D.length!==0&&(c=w(a,D),u=w())},P=()=>{if(l++>=s)throw new Error("drbg: tried max amount of iterations");let D=0,L=[];for(;D<t;){u=w();let U=u.slice();L.push(U),D+=u.length}return kt(...L)};return(D,L)=>{m(),E(D);let U;for(;(U=L(P()))===void 0;)E();return m(),U}}function pn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function i(o,a,s){if(!s&&a!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let u=e[o];if(s&&u===void 0)return;let c=typeof u;if(c!==a||u===null)throw new TypeError(`param "${o}" is invalid: expected ${a}, got ${c}`)}let n=(o,a)=>Object.entries(o).forEach(([s,u])=>i(s,u,a));n(t,!1),n(r,!0)}var qt,Zm,Pa,kt,Dc,Yu,ki,fp,Gm,up,Uc,Ju=Xr(()=>{v();gs();qt=(e,t,r)=>Io(e,t,r),Zm=ps,Pa=J2,kt=(...e)=>_O(...e),Dc=e=>jm(e),Yu=Hm,ki=e=>i0(e),fp=BigInt(0),Gm=BigInt(1);up=e=>typeof e=="bigint"&&fp<=e;Uc=e=>(Gm<<BigInt(e))-Gm});function Ui(e,t){if(t<=ti)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ti?r:t+r}function Fi(e,t,r){if(t<ti)throw new Error("pow2: expected non-negative exponent, got "+t);let i=e;for(;t-- >ti;)i*=i,i%=r;return i}function DO(e,t){if(e===ti)throw new Error("invert: expected non-zero number");if(t<=ti)throw new Error("invert: expected positive modulus, got "+t);let r=Ui(e,t),i=t,n=ti,o=wr,a=wr,s=ti;for(;r!==ti;){let c=i/r,l=i-r*c,m=n-a*c,w=o-s*c;i=r,r=l,n=a,o=s,a=m,s=w}if(i!==wr)throw new Error("invert: does not exist");return Ui(n,t)}function Xm(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw new Error("Cannot find square root")}function zO(e,t){let r=e,i=(r.ORDER+wr)/UO,n=r.pow(t,i);return Xm(r,n,t),n}function M$(e,t){let r=e,i=(r.ORDER-FO)/HO,n=r.mul(t,Qu),o=r.pow(n,i),a=r.mul(t,o),s=r.mul(r.mul(a,Qu),o),u=r.mul(a,r.sub(s,r.ONE));return Xm(r,u,t),u}function C$(e){let t=Fc(e),r=KO(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),a=(e+R$)/jO;return((s,u)=>{let c=s,l=c.pow(u,a),m=c.mul(l,i),w=c.mul(l,n),E=c.mul(l,o),P=c.eql(c.sqr(m),u),M=c.eql(c.sqr(w),u);l=c.cmov(l,m,P),m=c.cmov(E,w,M);let D=c.eql(c.sqr(m),u),L=c.cmov(l,m,D);return Xm(c,L,u),L})}function KO(e){if(e<qO)throw new Error("sqrt is not defined for small field");let t=e-wr,r=0;for(;t%Qu===ti;)t/=Qu,r++;let i=Qu,n=Fc(e);for(;$m(n,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return zO;let o=n.pow(i,t),a=(t+wr)/Qu;return function(u,c){let l=u;if(l.is0(c))return c;if($m(l,c)!==1)throw new Error("Cannot find square root");let m=r,w=l.mul(l.ONE,o),E=l.pow(c,t),P=l.pow(c,a);for(;!l.eql(E,l.ONE);){if(l.is0(E))return l.ZERO;let M=1,D=l.sqr(E);for(;!l.eql(D,l.ONE);)if(M++,D=l.sqr(D),M===m)throw new Error("Cannot find square root");let L=wr<<BigInt(m-M-1),U=l.pow(w,L);m=M,w=l.sqr(U),E=l.mul(E,w),P=l.mul(P,U)}return P}}function N$(e){return e%UO===qO?zO:e%HO===FO?M$:e%jO===B$?C$(e):KO(e)}function ef(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=D$.reduce((i,n)=>(i[n]="function",i),t);if(pn(e,r),dn(e.BYTES,"BYTES"),dn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=wr)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function L$(e,t,r){let i=e;if(r<ti)throw new Error("invalid exponent, negatives unsupported");if(r===ti)return i.ONE;if(r===wr)return t;let n=i.ONE,o=t;for(;r>ti;)r&wr&&(n=i.mul(n,o)),o=i.sqr(o),r>>=wr;return n}function tf(e,t,r=!1){let i=e,n=new Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((s,u,c)=>i.is0(u)?s:(n[c]=s,i.mul(s,u)),i.ONE),a=i.inv(o);return t.reduceRight((s,u,c)=>i.is0(u)?s:(n[c]=i.mul(s,n[c]),i.mul(s,u)),a),n}function $m(e,t){let r=e,i=(r.ORDER-wr)/Qu,n=r.pow(t,i),o=r.eql(n,r.ONE),a=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!a&&!s)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function Jm(e,t){return $m(e,t)!==-1}function q$(e,t){if(t!==void 0&&Zm(t),e<=ti)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Xu(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}function Fc(e,t={}){return new dp(e,t)}function VO(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=wr)throw new Error("field order must be greater than 1");let t=Xu(e-wr);return Math.ceil(t/8)}function u0(e){let t=VO(e);return t+Math.ceil(t/2)}function Hc(e,t,r=!1){qt(e);let i=e.length,n=VO(t),o=Math.max(u0(t),16);if(i<o||i>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+i);let a=r?Lc(e):bi(e),s=Ui(a,t-wr)+wr;return r?Wm(s,n):lp(s,n)}var ti,wr,Qu,qO,UO,FO,R$,HO,B$,jO,D$,LO,dp,jc=Xr(()=>{v();Ju();ti=BigInt(0),wr=BigInt(1),Qu=BigInt(2),qO=BigInt(3),UO=BigInt(4),FO=BigInt(5),R$=BigInt(7),HO=BigInt(8),B$=BigInt(9),jO=BigInt(16);D$=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];LO=new WeakMap,dp=class{constructor(t,r={}){Z(this,"ORDER");Z(this,"BITS");Z(this,"BYTES");Z(this,"isLE");Z(this,"ZERO",ti);Z(this,"ONE",wr);Z(this,"_lengths");Z(this,"_mod");if(t<=wr)throw new Error("invalid field: expected ORDER > 1, got "+t);let i;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(i=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:n,nByteLength:o}=q$(t,i);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=o,Object.freeze(this)}create(t){return Ui(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return ti<=t&&t<this.ORDER}is0(t){return t===ti}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&wr)===wr}neg(t){return Ui(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return Ui(t*t,this.ORDER)}add(t,r){return Ui(t+r,this.ORDER)}sub(t,r){return Ui(t-r,this.ORDER)}mul(t,r){return Ui(t*r,this.ORDER)}pow(t,r){return L$(this,t,r)}div(t,r){return Ui(t*DO(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return DO(t,this.ORDER)}sqrt(t){let r=LO.get(this);return r||LO.set(this,r=N$(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?Wm(t,this.BYTES):lp(t,this.BYTES)}fromBytes(t,r=!1){qt(t);let{_lengths:i,BYTES:n,isLE:o,ORDER:a,_mod:s}=this;if(i){if(t.length<1||!i.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=new Uint8Array(n);c.set(t,o?0:c.length-t.length),t=c}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let u=o?Lc(t):bi(t);if(s&&(u=Ui(u,a)),!r&&!this.isValid(u))throw new Error("invalid field element: outside of range 0..ORDER");return u}invertBatch(t){return tf(this,t)}cmov(t,r,i){return $u(i,"condition"),i?r:t}};Object.freeze(dp.prototype)});function YO(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");pn({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),ef(t.Fp),ef(t.Fn)}function f0(e,t){let r=t.negate();return e?r:t}function ry(e,t){let r=tf(e.Fp,t.map(i=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function $O(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Qm(e,t){$O(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Uc(e),a=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:a}}function GO(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:a}=r,s=Number(e&n),u=e>>a;s>i&&(s-=o,u+=rf);let c=t*i,l=c+Math.abs(s)-1,m=s===0,w=s<0,E=t%2!==0;return{nextN:u,offset:l,isZero:m,isNeg:w,isNegF:E,offsetF:c}}function U$(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,i)=>{if(!(r instanceof t))throw new Error("invalid point at index "+i)})}function F$(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,i)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+i)})}function ty(e){return XO.get(e)||1}function ZO(e){if(e!==zc)throw new Error("invalid wNAF")}function JO(e,t,r,i){let n=t,o=e.ZERO,a=e.ZERO;for(;r>zc||i>zc;)r&rf&&(o=o.add(n)),i&rf&&(a=a.add(n)),n=n.double(),r>>=rf,i>>=rf;return{p1:o,p2:a}}function QO(e,t,r){let i=e.Fn;U$(t,e),F$(r,i);let n=t.length,o=r.length;if(n!==o)throw new Error("arrays of points and scalars must have equal length");let a=e.ZERO,s=Xu(BigInt(n)),u=1;s>12?u=s-3:s>4?u=s-2:s>0&&(u=2);let c=Uc(u),l=new Array(Number(c)+1).fill(a),m=Math.floor((i.BITS-1)/u)*u,w=a;for(let E=m;E>=0;E-=u){l.fill(a);for(let M=0;M<o;M++){let D=r[M],L=Number(D>>BigInt(E)&c);l[L]=l[L].add(t[M])}let P=a;for(let M=l.length-1,D=a;M>0;M--)D=D.add(l[M]),P=P.add(D);if(w=w.add(P),E!==0)for(let M=0;M<u;M++)w=w.double()}return w}function WO(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ef(t),t}else return Fc(e,{isLE:r})}function eA(e,t,r={},i){if(i===void 0&&(i=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let u of["p","n","h"]){let c=t[u];if(!(typeof c=="bigint"&&c>zc))throw new Error(`CURVE.${u} must be positive bigint`)}let n=WO(t.p,r.Fp,i),o=WO(t.n,r.Fn,i),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let u of s)if(!n.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function gp(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}var zc,rf,ey,XO,pp,vp=Xr(()=>{v();Ju();jc();zc=BigInt(0),rf=BigInt(1);ey=new WeakMap,XO=new WeakMap;pp=class{constructor(t,r){Z(this,"BASE");Z(this,"ZERO");Z(this,"Fn");Z(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,i=this.ZERO){let n=t;for(;r>zc;)r&rf&&(i=i.add(n)),n=n.double(),r>>=rf;return i}precomputeWindow(t,r){let{windows:i,windowSize:n}=Qm(r,this.bits),o=[],a=t,s=a;for(let u=0;u<i;u++){s=a,o.push(s);for(let c=1;c<n;c++)s=s.add(a),o.push(s);a=s.double()}return o}wNAF(t,r,i){if(!this.Fn.isValid(i))throw new Error("invalid scalar");let n=this.ZERO,o=this.BASE,a=Qm(t,this.bits);for(let s=0;s<a.windows;s++){let{nextN:u,offset:c,isZero:l,isNeg:m,isNegF:w,offsetF:E}=GO(i,s,a);i=u,l?o=o.add(f0(w,r[E])):n=n.add(f0(m,r[c]))}return ZO(i),{p:n,f:o}}wNAFUnsafe(t,r,i,n=this.ZERO){let o=Qm(t,this.bits);for(let a=0;a<o.windows&&i!==zc;a++){let{nextN:s,offset:u,isZero:c,isNeg:l}=GO(i,a,o);if(i=s,!c){let m=r[u];n=n.add(l?m.negate():m)}}return ZO(i),n}getPrecomputes(t,r,i){let n=ey.get(r);return n||(n=this.precomputeWindow(r,t),t!==1&&(typeof i=="function"&&(n=i(n)),ey.set(r,n))),n}cached(t,r,i){let n=ty(t);return this.wNAF(n,this.getPrecomputes(n,t,i),r)}unsafe(t,r,i,n){let o=ty(t);return o===1?this._unsafeLadder(t,r,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),r,n)}createCache(t,r){$O(r,this.bits),XO.set(t,r),ey.delete(t)}hasCache(t){return ty(t)!==1}}});function tA(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function H$(e){if(tA(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<iy(e-1)+1>>>0}function iy(e){return tA(e),31-Math.clz32(e)}function rA(e,t,r,i,n){let o=e,a=r||((l,m)=>new Array(l).fill(m??o.ZERO)),s=l=>{if(Array.isArray(l))return!0;if(!ArrayBuffer.isView(l))return!1;let m=l;return typeof m.length=="number"&&typeof m.slice=="function"&&typeof m[Symbol.iterator]=="function"},u=(...l)=>{if(!l.length)return 0;for(let w of l)if(!s(w))throw new Error("poly: not polynomial: "+w);let m=l[0].length;for(let w=1;w<l.length;w++)if(l[w].length!==m)throw new Error(`poly: mismatched lengths ${m} vs ${l[w].length}`);if(n!==void 0&&m!==n)throw new Error(`poly: expected fixed length ${n}, got ${m}`);return m};function c(l,m,w=!1){let E=iy(m),P=w?t.brp(E):t.roots(E);for(let M=0;M<m;M++)if(o.eql(l,P[M]))return M;return-1}return{roots:t,create:a,length:n,extend:(l,m)=>{u(l);let w=a(m,o.ZERO);for(let E=0;E<Math.min(l.length,m);E++)w[E]=l[E];return w},degree:l=>{u(l);for(let m=l.length-1;m>=0;m--)if(!o.is0(l[m]))return m;return-1},add:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.add(l[P],m[P]);return E},sub:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.sub(l[P],m[P]);return E},dot:(l,m)=>{let w=u(l,m),E=a(w);for(let P=0;P<w;P++)E[P]=o.mul(l[P],m[P]);return E},mul:(l,m)=>{if(s(m)){let w=u(l,m);if(i){let E=i.direct(l,!1,!0),P=i.direct(m,!1,!0);for(let M=0;M<E.length;M++)E[M]=o.mul(E[M],P[M]);return i.inverse(E,!0,!1)}else{let E=a(w);for(let P=0;P<w;P++)for(let M=0;M<w;M++){let D=(P+M)%w;E[D]=o.add(E[D],o.mul(l[P],m[M]))}return E}}else{let w=a(u(l));for(let E=0;E<w.length;E++)w[E]=o.mul(l[E],m);return w}},convolve(l,m){let w=H$(l.length+m.length-1);return this.mul(this.extend(l,w),this.extend(m,w))},shift(l,m){let w=a(u(l));w[0]=l[0];for(let E=1,P=o.ONE;E<l.length;E++)P=o.mul(P,m),w[E]=o.mul(l[E],P);return w},clone:l=>{u(l);let m=a(l.length);for(let w=0;w<l.length;w++)m[w]=l[w];return m},eval:(l,m)=>{u(l,m);let w=o.ZERO;for(let E=0;E<l.length;E++)w=o.add(w,o.mul(l[E],m[E]));return w},monomial:{basis:(l,m)=>{let w=a(m),E=o.ONE;for(let P=0;P<m;P++)w[P]=E,E=o.mul(E,l);return w},eval:(l,m)=>{u(l);let w=o.ZERO;for(let E=l.length-1;E>=0;E--)w=o.add(o.mul(w,m),l[E]);return w}},lagrange:{basis:(l,m,w=!1,E)=>{let P=iy(m),M=E||(w?t.brp(P):t.roots(P)),D=a(m),L=c(l,m,w);if(L!==-1)return D[L]=o.ONE,D;let U=o.pow(l,BigInt(m)),K=o.mul(o.sub(U,o.ONE),o.inv(BigInt(m))),C=a(m);for(let F=0;F<m;F++)C[F]=o.sub(l,M[F]);let N=o.invertBatch(C);for(let F=0;F<m;F++)D[F]=o.mul(K,o.mul(M[F],N[F]));return D},eval(l,m,w=!1){u(l);let E=c(m,l.length,w);if(E!==-1)return l[E];let P=this.basis(m,l.length,w),M=o.ZERO;for(let D=0;D<l.length;D++)o.is0(l[D])||(M=o.add(M,o.mul(l[D],P[D])));return M}},vanishing(l){u(l);let m=a(l.length+1,o.ZERO);m[0]=o.ONE;for(let w of l){let E=o.neg(w);for(let P=m.length-1;P>0;P--)m[P]=o.add(o.mul(m[P],E),m[P-1]);m[0]=o.mul(m[0],E)}return m}}}var iA=Xr(()=>{v()});function nf(e,t){if(dn(e),dn(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function z$(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function nA(e){if(!Yu(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?qc(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function K$(e,t,r,i){qt(e),dn(r),t=nA(t),t.length>255&&(t=i(kt(qc("H2C-OVERSIZE-DST-"),t)));let{outputLen:n,blockLen:o}=i,a=Math.ceil(r/n);if(r>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");let s=kt(t,nf(t.length,1)),u=new Uint8Array(o),c=nf(r,2),l=new Array(a),m=i(kt(u,e,c,nf(0,1),s));l[0]=i(kt(m,nf(1,1),s));for(let E=1;E<a;E++){let P=[z$(m,l[E-1]),nf(E+1,1),s];l[E]=i(kt(...P))}return kt(...l).slice(0,r)}function V$(e,t,r,i,n){if(qt(e),dn(r),t=nA(t),t.length>255){let o=Math.ceil(2*i/8);t=n.create({dkLen:o}).update(qc("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(e).update(nf(r,2)).update(t).update(nf(t.length,1)).digest()}function ny(e,t,r){pn(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:i,k:n,m:o,hash:a,expand:s,DST:u}=r;if(dn(a.outputLen,"valid hash"),qt(e),dn(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let c=i.toString(2).length,l=Math.ceil((c+n)/8),m=t*o*l,w;if(s==="xmd")w=K$(e,u,m,a);else if(s==="xof")w=V$(e,u,m,n,a);else if(s==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let E=new Array(t);for(let P=0;P<t;P++){let M=new Array(o);for(let D=0;D<o;D++){let L=l*(D+P*o),U=w.subarray(L,L+l);M[D]=Ui(j$(U),i)}E[P]=M}return E}function oA(e,t){let r=t.map(i=>Array.from(i).reverse());return(i,n)=>{let[o,a,s,u]=r.map(m=>m.reduce((w,E)=>e.add(e.mul(w,i),E))),[c,l]=tf(e,[a,u],!0);return i=e.mul(o,c),n=e.mul(n,e.mul(s,l)),{x:i,y:n}}}function aA(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let i=s=>Object.freeze({...s,DST:Yu(s.DST)?hp(s.DST):s.DST,...s.encodeDST===void 0?{}:{encodeDST:Yu(s.encodeDST)?hp(s.encodeDST):s.encodeDST}}),n=i(r);function o(s){return e.fromAffine(t(s))}function a(s){let u=s.clearCofactor();return u.equals(e.ZERO)?e.ZERO:(u.assertValidity(),u)}return Object.freeze({get defaults(){return i(n)},Point:e,hashToCurve(s,u){let c=Object.assign({},n,u),l=ny(s,2,c),m=o(l[0]),w=o(l[1]);return a(m.add(w))},encodeToCurve(s,u){let c=n.encodeDST?{DST:n.encodeDST}:{},l=Object.assign({},n,c,u),m=ny(s,1,l),w=o(m[0]);return a(w)},mapToCurve(s){if(n.m===1){if(typeof s!="bigint")throw new Error("expected bigint (m=1)");return a(o([s]))}if(!Array.isArray(s))throw new Error("expected array of bigints");for(let u of s)if(typeof u!="bigint")throw new Error("expected array of bigints");return a(o(s))},hashToScalar(s,u){let c=e.Fn.ORDER,l=Object.assign({},n,{p:c,m:1,DST:G$},u);return ny(s,1,l)[0][0]}})}var j$,G$,sA=Xr(()=>{v();Ju();jc();j$=bi;G$="HashToScalar-"});function oy(e){pn(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),YO(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,i=e.hash,n=e.hashToScalar===void 0?(q,W={DST:new Uint8Array})=>{let $=i(kt(W.DST,q));return r.create(r.isLE?Lc($):bi($))}:e.hashToScalar,o=Ia(e.H1!==void 0?e.H1:e.name+"rho"),a=Ia(e.H2!==void 0?e.H2:e.name+"chal"),s=Ia(e.H3!==void 0?e.H3:e.name+"nonce"),u=Ia(e.H4!==void 0?e.H4:e.name+"msg"),c=Ia(e.H5!==void 0?e.H5:e.name+"com"),l=Ia(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),m=Ia(e.HID!==void 0?e.HID:e.name+"id"),w=q=>n(q,{DST:o}),E=q=>n(q,{DST:a}),P=q=>n(q,{DST:s}),M=q=>i(kt(u,q)),D=q=>i(kt(c,q)),L=q=>n(q,{DST:l}),U=q=>n(q,{DST:m}),K=(q=ki)=>{let W=Hc(q(u0(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Lc(W):bi(W)},C=q=>q.toBytes(),N=q=>{let W=t.fromBytes(q);return e.validatePoint&&e.validatePoint(W),W},F=(q,W)=>({identifier:q,hiding:C(t.BASE.multiply(r.fromBytes(W.hiding))),binding:C(t.BASE.multiply(r.fromBytes(W.binding)))}),H=e.adjustPoint===void 0?q=>q:e.adjustPoint,z=q=>{if(!r.isValid(q)||r.is0(q))throw new Error("Invalid identifier "+q);return q},V=q=>Pa(r.toBytes(z(q))),B=q=>{let W=z(r.fromBytes(Dc(q)));if(V(W)!==q)throw new Error("expected canonical identifier hex");return W},g={encode:(q,W)=>{let $=kt(C(q),r.toBytes(W));return e.adjustTx&&($=e.adjustTx.encode($)),$},decode:q=>{e.adjustTx&&(q=e.adjustTx.decode(q));let W=N(q.subarray(0,-r.BYTES)),$=r.fromBytes(q.subarray(-r.BYTES));return{R:W,z:$}}},I=(q=ki)=>{let W=K(q);e.adjustScalar&&(W=e.adjustScalar(W));let $=t.BASE.multiply(W);return{scalar:W,point:$}},y="roots are unavailable in FROST polynomial mode",f={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(y)},brp(){throw new Error(y)},inverse(){throw new Error(y)},omega(){throw new Error(y)},clear(){}},p=rA(r,f),_=(q,W)=>QO(t,q,W),x=(q,W)=>{if(!W.length)throw new Error("empty coefficients");return p.monomial.eval(W,q)},b=(q,W)=>{let $="invalid parameters";if(!q.some(le=>r.eql(le,W)))throw new Error($);let ee=new Set(q);if(ee.size!==q.length)throw new Error($);if(!ee.has(W))throw new Error($);let se=r.ONE,ue=r.ONE;for(let le of q)r.eql(le,W)||(se=r.mul(se,le),ue=r.mul(ue,r.sub(le,W)));return r.div(se,ue)},d=(q,W)=>{let $=p.monomial.basis(q,W.length);return _(W,$)},O=(q,W,$,ee=ki)=>{mp(q);let se=W===void 0?K(ee):r.fromBytes(W);if(!$){$=[];for(let Pe=0;Pe<q.min-1;Pe++)$.push(K(ee))}if($.length!==q.min-1)throw new Error("wrong coefficients length");let ue=[se,...$],le=ue.map(Pe=>t.BASE.multiply(Pe));return{coefficients:ue,commitment:le,secret:se}},T={challenge:(q,W,$)=>L(kt(r.toBytes(q),C(W),C($))),compute(q,W,$,ee=ki){if(W.length<1)throw new Error("coefficients should have at least one element");let{point:se,scalar:ue}=I(ee),le=$[0],Pe=this.challenge(q,le,se),ge=r.add(ue,r.mul(W[0],Pe));return g.encode(se,ge)},validate(q,W,$){if(W.length<1)throw new Error("commitment should have at least one element");let{R:ee,z:se}=g.decode($),ue=N(W[0]),le=this.challenge(q,ue,ee);if(!ee.equals(t.BASE.multiply(se).subtract(ue.multiply(le))))throw new Error("invalid proof of knowledge")}},S={challenge:(q,W,$)=>e.challenge?e.challenge(q,W,$):E(kt(C(q),C(W),$)),sign(q,W,$=ki){let{point:ee,scalar:se}=I($),ue=t.BASE.multiply(W),le=this.challenge(ee,ue,q),Pe=r.add(se,r.mul(le,W));return[ee,Pe]},verify(q,W,$,ee){e.adjustPoint&&(ee=e.adjustPoint(ee)),e.adjustPoint&&(W=e.adjustPoint(W));let se=this.challenge(W,ee,q),ue=t.BASE.multiply($),le=ee.multiply(se),Pe=ue.subtract(le).subtract(W);return Pe.clearCofactor&&(Pe=Pe.clearCofactor()),t.ZERO.equals(Pe)}},R=(q,W,$)=>{if(!t.BASE.multiply($).equals(d(q,W)))throw new Error("invalid secret share")},Y={fromNumber(q){if(!Number.isSafeInteger(q))throw new Error("expected safe interger");return V(BigInt(q))},derive(q){if(typeof q!="string")throw new Error("wrong identifier string: "+q);return V(U(Ia(q)))}},X=(q,W=ki)=>P(kt(W(32),r.toBytes(q))),ne=(q,W,$)=>{let ee=W.map(ye=>[ye.identifier,B(ye.identifier),N(ye.hiding),N(ye.binding)]);ee.sort((ye,Be)=>ye[1]<Be[1]?-1:ye[1]>Be[1]?1:0);let se=[];for(let[ye,Be,be,_e]of ee)se.push(r.toBytes(Be),C(be),C(_e));let ue=D(kt(...se)),le=kt(C(q),M($),ue),Pe={};for(let[ye,Be]of ee)Pe[ye]=w(kt(le,r.toBytes(Be)));let ge=[],ve=[];for(let[ye,Be,be,_e]of ee){if(t.ZERO.equals(be)||t.ZERO.equals(_e))throw new Error("infinity commitment");ge.push(be,_e),ve.push(r.ONE,Pe[ye])}let sr=_(ge,ve);return{identifiers:ee.map(ye=>ye[1]),groupCommitment:sr,bindingFactors:Pe}},ce=(q,W,$,ee)=>{let se=H(N(q)),ue=B(ee),{identifiers:le,groupCommitment:Pe,bindingFactors:ge}=ne(se,W,$),ve=ge[ee],sr=b(le,ue),xe=S.challenge(Pe,se,$);return{lambda:sr,challenge:xe,bindingFactor:ve,groupCommitment:Pe}};Object.freeze(Y);let pe={Identifier:Y,DKG:Object.freeze({round1:(q,W,$,ee=ki)=>{mp(W);let se=B(q),{coefficients:ue,commitment:le}=O(W,$,void 0,ee),Pe=T.compute(se,ue,le,ee),ge=le.map(C),ve={identifier:V(se),commitment:ge,proofOfKnowledge:Pe},sr={identifier:se,coefficients:ue,commitment:le.map(C),signers:{min:W.min,max:W.max},step:1};return{public:ve,secret:sr}},round2:(q,W)=>{if(W.length!==q.signers.max-1)throw new Error("wrong number of round1 packages");if(!q.coefficients||q.step===3)throw new Error("round3 package used in round2");let $={};for(let ee of W){if(ee.commitment.length!==q.signers.min)throw new Error("wrong number of commitments");let se=B(ee.identifier);if(se===q.identifier)throw new Error("duplicate id="+V(se));T.validate(se,ee.commitment,ee.proofOfKnowledge);for(let le of ee.commitment)N(le);if($[ee.identifier])throw new Error("Duplicate id="+se);let ue=r.toBytes(x(se,q.coefficients));$[ee.identifier]={identifier:V(q.identifier),signingShare:ue}}return q.step=2,$},round3:(q,W,$)=>{if(W.length!==q.signers.max-1)throw new Error("wrong length of round1 packages");if(!q.coefficients||q.step!==2)throw new Error("round2 package used in round3");if($.length!==W.length)throw new Error("wrong length of round2 packages");let ee={};for(let Be of W){if(!Be.identifier||!Be.commitment)throw new Error("wrong round1 share");ee[Be.identifier]={...Be}}for(let Be of $){if(!Be.identifier||!Be.signingShare)throw new Error("wrong round2 share");if(!ee[Be.identifier])throw new Error("round1 share for "+Be.identifier+" is missing");ee[Be.identifier].signingShare=Be.signingShare}if(Object.keys(ee).length!==W.length)throw new Error("mismatch identifiers between rounds");let se=r.ZERO;if(q.commitment.length!==q.signers.min)throw new Error("wrong commitments length");let ue=q.commitment.map(N),le=x(q.identifier,q.coefficients);R(q.identifier,ue,le);let Pe=ue.map(C),ge={[V(q.identifier)]:Pe};for(let Be in ee){let be=ee[Be];if(!be.signingShare||!be.commitment)throw new Error("mismatch identifiers");let _e=B(Be),Qi=r.fromBytes(be.signingShare),Ce=be.commitment.map(N);R(q.identifier,Ce,Qi),se=r.add(se,Qi);let Re=V(_e);if(ge[Re])throw new Error("duplicated id="+Re);ge[Re]=be.commitment}se=r.add(se,le);let ve=new Array(q.signers.min).fill(t.ZERO);for(let Be in ge){let be=ge[Be];if(be.length!==q.signers.min)throw new Error("wrong commitments length");for(let _e=0;_e<be.length;_e++)ve[_e]=ve[_e].add(N(be[_e]))}let sr=ve.map(C),xe={};for(let Be in ge)xe[Be]=C(d(B(Be),ve));let ye={public:{signers:{min:q.signers.min,max:q.signers.max},commitments:sr,verifyingShares:Object.fromEntries(Object.entries(xe).map(([Be,be])=>[Be,be.slice()]))},secret:{identifier:V(q.identifier),signingShare:r.toBytes(se)}};e.adjustDKG&&(ye=e.adjustDKG(ye));for(let Be=0;Be<q.coefficients.length;Be++)q.coefficients[Be]-=q.coefficients[Be];return delete q.coefficients,q.step=3,ye},clean(q){if(q.identifier-=q.identifier,q.coefficients)for(let W=0;W<q.coefficients.length;W++)q.coefficients[W]-=q.coefficients[W];q.step=3}}),trustedDealer(q,W,$,ee=ki){if(mp(q),W===void 0){W=[];for(let ve=1;ve<=q.max;ve++)W.push(Y.fromNumber(ve))}else if(!Array.isArray(W)||W.length!==q.max)throw new Error("identifiers should be array of "+q.max);let se={};for(let ve of W){let sr=B(ve);if(ve in se)throw new Error("duplicated id="+ve);se[ve]=sr}let ue=O(q,$,void 0,ee),le=ue.commitment.map(C),Pe={},ge={};for(let ve of W){let sr=x(se[ve],ue.coefficients);ge[ve]=C(t.BASE.multiply(sr)),Pe[ve]={identifier:ve,signingShare:r.toBytes(sr)}}return{public:{signers:{min:q.min,max:q.max},commitments:le,verifyingShares:ge},secretShares:Pe}},validateSecret(q,W){let $=B(q.identifier),ee=W.commitments.map(N),se=r.fromBytes(q.signingShare);R($,ee,se)},commit(q,W=ki){let $=r.fromBytes(q.signingShare),ee=X($,W),se=X($,W),ue={hiding:r.toBytes(ee),binding:r.toBytes(se)};return{nonces:ue,commitments:F(q.identifier,ue)}},signShare(q,W,$,ee,se){uA(W.signers,ee.length);let ue=r.fromBytes($.hiding),le=r.fromBytes($.binding);if(r.is0(ue)||r.is0(le))throw new Error("signing nonces already used");let Pe={identifier:q.identifier,hiding:C(t.BASE.multiply(ue)),binding:C(t.BASE.multiply(le))},ge=ee.find(De=>De.identifier===q.identifier);if(!ge)throw new Error("missing signer commitment");if(Pa(ge.hiding)!==Pa(Pe.hiding)||Pa(ge.binding)!==Pa(Pe.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(q=e.adjustSecret(q,W)),e.adjustPublic&&(W=e.adjustPublic(W));let ve=r.fromBytes(q.signingShare),{lambda:sr,challenge:xe,bindingFactor:ye,groupCommitment:Be}=ce(W.commitments[0],ee,se,q.identifier),be=e.adjustNonces?e.adjustNonces(Be,$):$,_e=e.adjustNonces?r.fromBytes(be.hiding):ue,Qi=e.adjustNonces?r.fromBytes(be.binding):le,Ce=r.mul(r.mul(sr,ve),xe),Re=r.mul(Qi,ye),Js=r.toBytes(r.add(r.add(_e,Re),Ce));return $.hiding.fill(0),$.binding.fill(0),Js},verifyShare(q,W,$,ee,se){e.adjustPublic&&(q=e.adjustPublic(q));let ue=W.find(Qi=>Qi.identifier===ee);if(!ue)throw new Error("cannot find identifier commitment");let le=N(q.verifyingShares[ee]),Pe=N(ue.hiding),ge=N(ue.binding),{lambda:ve,challenge:sr,bindingFactor:xe,groupCommitment:ye}=ce(q.commitments[0],W,$,ee),Be=Pe.add(ge.multiply(xe));e.adjustGroupCommitmentShare&&(Be=e.adjustGroupCommitmentShare(ye,Be));let be=t.BASE.multiply(r.fromBytes(se)),_e=Be.add(le.multiply(r.mul(sr,ve)));return be.equals(_e)},aggregate(q,W,$,ee){e.adjustPublic&&(q=e.adjustPublic(q));try{uA(q.signers,W.length)}catch{throw new Kc("aggregation failed",[])}let se=W.map(ge=>ge.identifier);if(se.length!==Object.keys(ee).length)throw new Kc("aggregation failed",[]);for(let ge of se)if(!(ge in ee)||!(ge in q.verifyingShares))throw new Kc("aggregation failed",[]);let ue=N(q.commitments[0]),{groupCommitment:le}=ne(ue,W,$),Pe=r.ZERO;for(let ge of se)Pe=r.add(Pe,r.fromBytes(ee[ge]));if(!S.verify($,le,Pe,ue)){let ge=[];for(let ve of se)this.verifyShare(q,W,$,ve,ee[ve])||ge.push(ve);throw new Kc("aggregation failed",ge)}return g.encode(le,Pe)},sign(q,W){let $=r.fromBytes(W);e.adjustScalar&&($=e.adjustScalar($));let[ee,se]=S.sign(q,$);return g.encode(ee,se)},verify(q,W,$){let ee=e.parsePublicKey?e.parsePublicKey($):N($),{R:se,z:ue}=g.decode(q);return S.verify(W,se,ue,ee)},combineSecret(q,W){if(mp(W),!Array.isArray(q)||q.length<W.min)throw new Error("wrong secret shares array");let $=[],ee={};for(let le of q){let Pe=B(le.identifier),ge=V(Pe);if(ee[ge])throw new Error("duplicated id="+ge);ee[ge]=!0,$.push([Pe,r.fromBytes(le.signingShare)])}let se=$.map(([le])=>le),ue=r.ZERO;for(let[le,Pe]of $)ue=r.add(ue,r.mul(Pe,b(se,le)));return r.toBytes(ue)},utils:Object.freeze({Fn:r,randomScalar:(q=ki)=>r.toBytes(I(q).scalar),generateSecretPolynomial:(q,W,$,ee)=>{let se=O(q,W,$,ee);return{...se,commitment:se.commitment.map(C)}}})};return Object.freeze(pe)}var mp,uA,Kc,fA=Xr(()=>{v();gs();Ju();vp();iA();jc();mp=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},uA=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Kc=class extends Error{constructor(r,i){super(r);Z(this,"cheaters");this.cheaters=i}}});var sy={};X1(sy,{_HMAC:()=>c0,hmac:()=>ay});var c0,ay,yp=Xr(()=>{v();gs();c0=class{constructor(t,r){Z(this,"oHash");Z(this,"iHash");Z(this,"blockLen");Z(this,"outputLen");Z(this,"canXOF",!1);Z(this,"finished",!1);Z(this,"destroyed",!1);if(Y2(t),Io(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,n=new Uint8Array(i);n.set(r.length>i?t.create().update(r).digest():r);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=t.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),Ea(n)}update(t){return Cc(this),this.iHash.update(t),this}digestInto(t){Cc(this),$2(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:i,finished:n,destroyed:o,blockLen:a,outputLen:s}=this;return t=t,t.finished=n,t.destroyed=o,t.blockLen=a,t.outputLen=s,t.oHash=r._cloneInto(t.oHash),t.iHash=i._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ay=(()=>{let e=((t,r,i)=>new c0(t,r).update(i).digest());return e.create=(t,r)=>new c0(t,r),e})()});function Z$(e,t,r){Ym("scalar",e,gn,r);let[[i,n],[o,a]]=t,s=cA(a*e,r),u=cA(-n*e,r),c=e-s*i-u*o,l=-s*n-u*a,m=c<gn,w=l<gn;m&&(c=-c),w&&(l=-l);let E=Uc(Math.ceil(Xu(r)/2))+Kr;if(c<gn||c>=E||l<gn||l>=E)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:m,k1:c,k2neg:w,k2:l}}function fy(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function uy(e,t){pn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];return $u(r.lowS,"lowS"),$u(r.prehash,"prehash"),r.format!==void 0&&fy(r.format),r}function lA(e,t={}){let r=eA("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:a,n:s}=o;pn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:u,allowInfinityPoint:c}=t;if(u&&(!i.is0(o.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=pA(i,n);function m(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function w(I,y,f){if(c&&y.is0())return Uint8Array.of(0);let{x:p,y:_}=y.toAffine(),x=i.toBytes(p);if($u(f,"isCompressed"),f){m();let b=!i.isOdd(_);return kt(hA(b),x)}else return kt(Uint8Array.of(4),x,i.toBytes(_))}function E(I){qt(I,void 0,"Point");let{publicKey:y,publicKeyUncompressed:f}=l,p=I.length,_=I[0],x=I.subarray(1);if(c&&p===1&&_===0)return{x:i.ZERO,y:i.ZERO};if(p===y&&(_===2||_===3)){let b=i.fromBytes(x);if(!i.isValid(b))throw new Error("bad point: is not on curve, wrong x");let d=D(b),O;try{O=i.sqrt(d)}catch(R){let Y=R instanceof Error?": "+R.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}m();let T=i.isOdd(O);return(_&1)===1!==T&&(O=i.neg(O)),{x:b,y:O}}else if(p===f&&_===4){let b=i.BYTES,d=i.fromBytes(x.subarray(0,b)),O=i.fromBytes(x.subarray(b,b*2));if(!L(d,O))throw new Error("bad point: is not on curve");return{x:d,y:O}}else throw new Error(`bad point: got length ${p}, expected compressed=${y} or uncompressed=${f}`)}let P=t.toBytes===void 0?w:t.toBytes,M=t.fromBytes===void 0?E:t.fromBytes;function D(I){let y=i.sqr(I),f=i.mul(y,I);return i.add(i.add(f,i.mul(I,o.a)),o.b)}function L(I,y){let f=i.sqr(y),p=D(I);return i.eql(f,p)}if(!L(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let U=i.mul(i.pow(o.a,Vc),ly),K=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(U,K)))throw new Error("bad curve params: a or b");function C(I,y,f=!1){if(!i.isValid(y)||f&&i.is0(y))throw new Error(`bad point coordinate ${I}`);return y}function N(I){if(!(I instanceof z))throw new Error("Weierstrass Point expected")}function F(I){if(!u||!u.basises)throw new Error("no endo");return Z$(I,u.basises,n.ORDER)}function H(I,y,f,p,_){return f=new z(i.mul(f.X,I),f.Y,f.Z),y=f0(p,y),f=f0(_,f),y.add(f)}let g=class g{constructor(y,f,p){Z(this,"X");Z(this,"Y");Z(this,"Z");this.X=C("x",y),this.Y=C("y",f,!0),this.Z=C("z",p),Object.freeze(this)}static CURVE(){return o}static fromAffine(y){let{x:f,y:p}=y||{};if(!y||!i.isValid(f)||!i.isValid(p))throw new Error("invalid affine point");if(y instanceof g)throw new Error("projective point not allowed");return i.is0(f)&&i.is0(p)?g.ZERO:new g(f,p,i.ONE)}static fromBytes(y){let f=g.fromAffine(M(qt(y,void 0,"point")));return f.assertValidity(),f}static fromHex(y){return g.fromBytes(Dc(y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,f=!0){return B.createCache(this,y),f||this.multiply(Vc),this}assertValidity(){let y=this;if(y.is0()){if(t.allowInfinityPoint&&i.is0(y.X)&&i.eql(y.Y,i.ONE)&&i.is0(y.Z))return;throw new Error("bad point: ZERO")}let{x:f,y:p}=y.toAffine();if(!i.isValid(f)||!i.isValid(p))throw new Error("bad point: x or y not field elements");if(!L(f,p))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(y)}equals(y){N(y);let{X:f,Y:p,Z:_}=this,{X:x,Y:b,Z:d}=y,O=i.eql(i.mul(f,d),i.mul(x,_)),T=i.eql(i.mul(p,d),i.mul(b,_));return O&&T}negate(){return new g(this.X,i.neg(this.Y),this.Z)}double(){let{a:y,b:f}=o,p=i.mul(f,Vc),{X:_,Y:x,Z:b}=this,d=i.ZERO,O=i.ZERO,T=i.ZERO,S=i.mul(_,_),R=i.mul(x,x),Y=i.mul(b,b),X=i.mul(_,x);return X=i.add(X,X),T=i.mul(_,b),T=i.add(T,T),d=i.mul(y,T),O=i.mul(p,Y),O=i.add(d,O),d=i.sub(R,O),O=i.add(R,O),O=i.mul(d,O),d=i.mul(X,d),T=i.mul(p,T),Y=i.mul(y,Y),X=i.sub(S,Y),X=i.mul(y,X),X=i.add(X,T),T=i.add(S,S),S=i.add(T,S),S=i.add(S,Y),S=i.mul(S,X),O=i.add(O,S),Y=i.mul(x,b),Y=i.add(Y,Y),S=i.mul(Y,X),d=i.sub(d,S),T=i.mul(Y,R),T=i.add(T,T),T=i.add(T,T),new g(d,O,T)}add(y){N(y);let{X:f,Y:p,Z:_}=this,{X:x,Y:b,Z:d}=y,O=i.ZERO,T=i.ZERO,S=i.ZERO,R=o.a,Y=i.mul(o.b,Vc),X=i.mul(f,x),ne=i.mul(p,b),ce=i.mul(_,d),pe=i.add(f,p),q=i.add(x,b);pe=i.mul(pe,q),q=i.add(X,ne),pe=i.sub(pe,q),q=i.add(f,_);let W=i.add(x,d);return q=i.mul(q,W),W=i.add(X,ce),q=i.sub(q,W),W=i.add(p,_),O=i.add(b,d),W=i.mul(W,O),O=i.add(ne,ce),W=i.sub(W,O),S=i.mul(R,q),O=i.mul(Y,ce),S=i.add(O,S),O=i.sub(ne,S),S=i.add(ne,S),T=i.mul(O,S),ne=i.add(X,X),ne=i.add(ne,X),ce=i.mul(R,ce),q=i.mul(Y,q),ne=i.add(ne,ce),ce=i.sub(X,ce),ce=i.mul(R,ce),q=i.add(q,ce),X=i.mul(ne,q),T=i.add(T,X),X=i.mul(W,q),O=i.mul(pe,O),O=i.sub(O,X),X=i.mul(pe,ne),S=i.mul(W,S),S=i.add(S,X),new g(O,T,S)}subtract(y){return N(y),this.add(y.negate())}is0(){return this.equals(g.ZERO)}multiply(y){let{endo:f}=t;if(!n.isValidNot0(y))throw new RangeError("invalid scalar: out of range");let p,_,x=b=>B.cached(this,b,d=>ry(g,d));if(f){let{k1neg:b,k1:d,k2neg:O,k2:T}=F(y),{p:S,f:R}=x(d),{p:Y,f:X}=x(T);_=R.add(X),p=H(f.beta,S,Y,b,O)}else{let{p:b,f:d}=x(y);p=b,_=d}return ry(g,[p,_])[0]}multiplyUnsafe(y){let{endo:f}=t,p=this,_=y;if(!n.isValid(_))throw new RangeError("invalid scalar: out of range");if(_===gn||p.is0())return g.ZERO;if(_===Kr)return p;if(B.hasCache(this))return this.multiply(_);if(f){let{k1neg:x,k1:b,k2neg:d,k2:O}=F(_),{p1:T,p2:S}=JO(g,p,b,O);return H(f.beta,T,S,x,d)}else return B.unsafe(p,_)}toAffine(y){let f=this,p=y,{X:_,Y:x,Z:b}=f;if(i.eql(b,i.ONE))return{x:_,y:x};let d=f.is0();p==null&&(p=d?i.ONE:i.inv(b));let O=i.mul(_,p),T=i.mul(x,p),S=i.mul(b,p);if(d)return{x:i.ZERO,y:i.ZERO};if(!i.eql(S,i.ONE))throw new Error("invZ was invalid");return{x:O,y:T}}isTorsionFree(){let{isTorsionFree:y}=t;return a===Kr?!0:y?y(g,this):B.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:y}=t;return a===Kr?this:y?y(g,this):this.multiplyUnsafe(a)}isSmallOrder(){return a===Kr?this.is0():this.clearCofactor().is0()}toBytes(y=!0){return $u(y,"isCompressed"),this.assertValidity(),P(g,this,y)}toHex(y=!0){return Pa(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};Z(g,"BASE",new g(o.Gx,o.Gy,i.ONE)),Z(g,"ZERO",new g(i.ZERO,i.ONE,i.ZERO)),Z(g,"Fp",i),Z(g,"Fn",n);let z=g,V=n.BITS,B=new pp(z,t.endo?Math.ceil(V/2):V);return V>=8&&z.BASE.precompute(8),Object.freeze(z.prototype),Object.freeze(z),z}function hA(e){return Uint8Array.of(e?2:3)}function W$(e,t){let r=ef(e),i=r.ORDER,n=gn;for(let M=i-Kr;M%Ao===gn;M/=Ao)n+=Kr;let o=n,a=Ao<<o-Kr-Kr,s=a*Ao,u=(i-Kr)/s,c=(u-Kr)/Ao,l=s-Kr,m=a,w=r.pow(t,u),E=r.pow(t,(u+Kr)/Ao),P=(M,D)=>{let L=w,U=r.pow(D,l),K=r.sqr(U);K=r.mul(K,D);let C=r.mul(M,K);C=r.pow(C,c),C=r.mul(C,U),U=r.mul(C,D),K=r.mul(C,M);let N=r.mul(K,U);C=r.pow(N,m);let F=r.eql(C,r.ONE);U=r.mul(K,E),C=r.mul(N,L),K=r.cmov(U,K,F),N=r.cmov(C,N,F);for(let H=o;H>Kr;H--){let z=H-Ao;z=Ao<<z-Kr;let V=r.pow(N,z),B=r.eql(V,r.ONE);U=r.mul(K,L),L=r.mul(L,L),V=r.mul(N,L),K=r.cmov(U,K,B),N=r.cmov(V,N,B)}return{isValid:!r.is0(D)&&(F||r.is0(M)),value:K}};if(r.ORDER%ly===Vc){let M=(r.ORDER-Vc)/ly,D=r.sqrt(r.neg(t));P=(L,U)=>{let K=r.sqr(U),C=r.mul(L,U);K=r.mul(K,C);let N=r.pow(K,M);N=r.mul(N,C);let F=r.mul(N,D),H=r.mul(r.sqr(N),U),z=r.eql(H,L),V=r.cmov(F,N,z);return{isValid:!r.is0(U)&&z,value:V}}}return P}function dA(e,t){let r=ef(e),{A:i,B:n,Z:o}=t;if(!r.isValidNot0(i)||!r.isValidNot0(n)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||Jm(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let a=r.mul(n,r.inv(r.mul(o,i))),s=r.add(r.add(r.mul(r.sqr(a),a),r.mul(i,a)),n);if(!Jm(r,s))throw new Error("mapToCurveSimpleSWU: invalid opts");let u=W$(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return c=>{let l,m,w,E,P,M,D,L;l=r.sqr(c),l=r.mul(l,o),m=r.sqr(l),m=r.add(m,l),w=r.add(m,r.ONE),w=r.mul(w,n),E=r.cmov(o,r.neg(m),!r.eql(m,r.ZERO)),E=r.mul(E,i),m=r.sqr(w),M=r.sqr(E),P=r.mul(M,i),m=r.add(m,P),m=r.mul(m,w),M=r.mul(M,E),P=r.mul(M,n),m=r.add(m,P),D=r.mul(l,w);let{isValid:U,value:K}=u(m,M);L=r.mul(l,c),L=r.mul(L,K),D=r.cmov(D,w,U),L=r.cmov(L,K,U);let C=r.isOdd(c)===r.isOdd(L);L=r.cmov(r.neg(L),L,C);let N=tf(r,[E],!0)[0];return D=r.mul(D,N),{x:D,y:L}}}function pA(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Y$(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?ki:t.randomBytes,n=Object.assign(pA(e.Fp,r),{seed:Math.max(u0(r.ORDER),16)});function o(E){try{let P=r.fromBytes(E);return r.isValidNot0(P)}catch{return!1}}function a(E,P){let{publicKey:M,publicKeyUncompressed:D}=n;try{let L=E.length;return P===!0&&L!==M||P===!1&&L!==D?!1:!!e.fromBytes(E)}catch{return!1}}function s(E){return E=E===void 0?i(n.seed):E,Hc(qt(E,n.seed,"seed"),r.ORDER)}function u(E,P=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(P)}function c(E){let{secretKey:P,publicKey:M,publicKeyUncompressed:D}=n,L=r._lengths;if(!Yu(E))return;let U=qt(E,void 0,"key").length,K=U===M||U===D,C=U===P||!!L?.includes(U);if(!(K&&C))return K}function l(E,P,M=!0){if(c(E)===!0)throw new Error("first arg must be private key");if(c(P)===!1)throw new Error("second arg must be public key");let D=r.fromBytes(E);return e.fromBytes(P).multiply(D).toBytes(M)}let m={isValidSecretKey:o,isValidPublicKey:a,randomSecretKey:s},w=gp(s,u);return Object.freeze(m),Object.freeze(n),Object.freeze({getPublicKey:u,getSharedSecret:l,keygen:w,Point:e,utils:m,lengths:n})}function gA(e,t,r={}){let i=t;Y2(i),pn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?ki:r.randomBytes,o=r.hmac===void 0?(p,_)=>ay(i,p,_):r.hmac,{Fp:a,Fn:s}=e,{ORDER:u,BITS:c}=s,{keygen:l,getPublicKey:m,getSharedSecret:w,utils:E,lengths:P}=Y$(e,r),M={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},D=u*Ao+Kr<a.ORDER;function L(p){let _=u>>Kr;return p>_}function U(p,_){if(!s.isValidNot0(_))throw new Error(`invalid signature ${p}: out of range 1..Point.Fn.ORDER`);return _}function K(){if(D)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(p,_){fy(_);let x=P.signature,b=_==="compact"?x:_==="recovered"?x+1:void 0;return qt(p,b)}class N{constructor(_,x,b){Z(this,"r");Z(this,"s");Z(this,"recovery");if(this.r=U("r",_),this.s=U("s",x),b!=null){if(K(),![0,1,2,3].includes(b))throw new Error("invalid recovery id");this.recovery=b}Object.freeze(this)}static fromBytes(_,x=M.format){C(_,x);let b;if(x==="der"){let{r:S,s:R}=Hn.toSig(qt(_));return new N(S,R)}x==="recovered"&&(b=_[0],x="compact",_=_.subarray(1));let d=P.signature/2,O=_.subarray(0,d),T=_.subarray(d,d*2);return new N(s.fromBytes(O),s.fromBytes(T),b)}static fromHex(_,x){return this.fromBytes(Dc(_),x)}assertRecovery(){let{recovery:_}=this;if(_==null)throw new Error("invalid recovery id: must be present");return _}addRecoveryBit(_){return new N(this.r,this.s,_)}recoverPublicKey(_){let{r:x,s:b}=this,d=this.assertRecovery(),O=d===2||d===3?x+u:x;if(!a.isValid(O))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let T=a.toBytes(O),S=e.fromBytes(kt(hA((d&1)===0),T)),R=s.inv(O),Y=H(qt(_,void 0,"msgHash")),X=s.create(-Y*R),ne=s.create(b*R),ce=e.BASE.multiplyUnsafe(X).add(S.multiplyUnsafe(ne));if(ce.is0())throw new Error("invalid recovery: point at infinify");return ce.assertValidity(),ce}hasHighS(){return L(this.s)}toBytes(_=M.format){if(fy(_),_==="der")return Dc(Hn.hexFromSig(this));let{r:x,s:b}=this,d=s.toBytes(x),O=s.toBytes(b);return _==="recovered"?(K(),kt(Uint8Array.of(this.assertRecovery()),d,O)):kt(d,O)}toHex(_){return Pa(this.toBytes(_))}}Object.freeze(N.prototype),Object.freeze(N);let F=r.bits2int===void 0?function(_){if(_.length>8192)throw new Error("input is too large");let x=bi(_),b=_.length*8-c;return b>0?x>>BigInt(b):x}:r.bits2int,H=r.bits2int_modN===void 0?function(_){return s.create(F(_))}:r.bits2int_modN,z=Uc(c);function V(p){return Ym("num < 2^"+c,p,gn,z),s.toBytes(p)}function B(p,_){return qt(p,void 0,"message"),_?qt(i(p),void 0,"prehashed message"):p}function g(p,_,x){let{lowS:b,prehash:d,extraEntropy:O}=uy(x,M);p=B(p,d);let T=H(p),S=s.fromBytes(_);if(!s.isValidNot0(S))throw new Error("invalid private key");let R=[V(S),V(T)];if(O!=null&&O!==!1){let ce=O===!0?n(P.secretKey):O;R.push(qt(ce,void 0,"extraEntropy"))}let Y=kt(...R),X=T;function ne(ce){let pe=F(ce);if(!s.isValidNot0(pe))return;let q=s.inv(pe),W=e.BASE.multiply(pe).toAffine(),$=s.create(W.x);if($===gn)return;let ee=s.create(q*s.create(X+$*S));if(ee===gn)return;let se=(W.x===$?0:2)|Number(W.y&Kr),ue=ee;return b&&L(ee)&&(ue=s.neg(ee),se^=1),new N($,ue,D?void 0:se)}return{seed:Y,k2sig:ne}}function I(p,_,x={}){let{seed:b,k2sig:d}=g(p,_,x);return NO(i.outputLen,s.BYTES,o)(b,d).toBytes(x.format)}function y(p,_,x,b={}){let{lowS:d,prehash:O,format:T}=uy(b,M);if(x=qt(x,void 0,"publicKey"),_=B(_,O),!Yu(p)){let S=p instanceof N?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+S)}C(p,T);try{let S=N.fromBytes(p,T),R=e.fromBytes(x);if(d&&S.hasHighS())return!1;let{r:Y,s:X}=S,ne=H(_),ce=s.inv(X),pe=s.create(ne*ce),q=s.create(Y*ce),W=e.BASE.multiplyUnsafe(pe).add(R.multiplyUnsafe(q));return W.is0()?!1:s.create(W.x)===Y}catch{return!1}}function f(p,_,x={}){let{prehash:b}=uy(x,M);return _=B(_,b),N.fromBytes(p,"recovered").recoverPublicKey(_).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:w,utils:E,lengths:P,Point:e,sign:I,verify:y,recoverPublicKey:f,Signature:N,hash:i})}var cA,cy,Hn,gn,Kr,Ao,Vc,ly,vA=Xr(()=>{v();yp();gs();Ju();vp();jc();cA=(e,t)=>(e+(e>=0?t:-t)/Ao)/t;cy=class extends Error{constructor(t=""){super(t)}},Hn={Err:cy,_tlv:{encode:(e,t)=>{let{Err:r}=Hn;if(dn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=s0(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?s0(n.length/2|128):"";return s0(e)+o+n+t},decode(e,t){let{Err:r}=Hn;t=qt(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),a=0;if(!o)a=n;else{let u=n&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");let c=t.subarray(i,i+u);if(c.length!==u)throw new r("tlv.decode: length bytes not complete");if(c[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of c)a=a<<8|l;if(i+=u,a<128)throw new r("tlv.decode(long): not minimal encoding")}let s=t.subarray(i,i+a);if(s.length!==a)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+a)}}},_int:{encode(e){let{Err:t}=Hn;if(cp(e),e<gn)throw new t("integer: negative integers are not allowed");let r=s0(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Hn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return bi(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Hn,n=qt(e,void 0,"signature"),{v:o,l:a}=i.decode(48,n);if(a.length)throw new t("invalid signature: left bytes after parsing");let{v:s,l:u}=i.decode(2,o),{v:c,l}=i.decode(2,u);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(s),s:r.decode(c)}},hexFromSig(e){let{_tlv:t,_int:r}=Hn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Hn._tlv);Object.freeze(Hn._int);Object.freeze(Hn);gn=BigInt(0),Kr=BigInt(1),Ao=BigInt(2),Vc=BigInt(3),ly=BigInt(4)});var h0={};X1(h0,{__TEST:()=>eX,schnorr:()=>tX,schnorr_FROST:()=>uX,secp256k1:()=>J$,secp256k1_FROST:()=>nX,secp256k1_hasher:()=>py});function X$(e){let t=bp.p,r=BigInt(3),i=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,l=c*c*e%t,m=Fi(l,r,t)*l%t,w=Fi(m,r,t)*l%t,E=Fi(w,hy,t)*c%t,P=Fi(E,n,t)*E%t,M=Fi(P,o,t)*P%t,D=Fi(M,s,t)*M%t,L=Fi(D,u,t)*D%t,U=Fi(L,s,t)*M%t,K=Fi(U,r,t)*l%t,C=Fi(K,a,t)*P%t,N=Fi(C,i,t)*c%t,F=Fi(N,hy,t);if(!Ta.eql(Ta.sqr(F),e))throw new Error("Cannot find square root");return F}function l0(e,...t){let r=mA[e];if(r===void 0){let i=bs(qc(e));r=kt(i,i),mA[e]=r}return bs(kt(r,...t))}function wA(e){let{Fn:t,BASE:r}=Ut,i=t.fromBytes(e),n=r.multiply(i);return{scalar:Po(n.y)?i:t.neg(i),bytes:of(n)}}function _p(e){let t=Ta;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),i=t.create(r*e+BigInt(7)),n=t.sqrt(i);Po(n)||(n=t.neg(n));let o=Ut.fromAffine({x:e,y:n});return o.assertValidity(),o}function dy(...e){return Ut.Fn.create(Gc(l0("BIP0340/challenge",...e)))}function yA(e){return wA(e).bytes}function Q$(e,t,r=i0(32)){let{Fn:i,BASE:n}=Ut,o=qt(e,void 0,"message"),{bytes:a,scalar:s}=wA(t),u=qt(r,32,"auxRand"),c=i.toBytes(s^Gc(l0("BIP0340/aux",u))),l=l0("BIP0340/nonce",c,a,o),m=i.create(Gc(l));if(m===0n)throw new Error("sign failed: k is zero");let w=n.multiply(m),E=Po(w.y)?m:i.neg(m),P=of(w),M=dy(P,a,o),D=new Uint8Array(64);if(D.set(P,0),D.set(i.toBytes(i.create(E+M*s)),32),!SA(D,o,a))throw new Error("sign: Invalid signature produced");return D}function SA(e,t,r){let{Fp:i,Fn:n,BASE:o}=Ut,a=qt(e,64,"signature"),s=qt(t,void 0,"message"),u=qt(r,32,"publicKey");try{let c=_p(Gc(u)),l=Gc(a.subarray(0,32));if(!i.isValidNot0(l))return!1;let m=Gc(a.subarray(32,64));if(!n.isValidNot0(m))return!1;let w=dy(n.toBytes(l),of(c),s),E=o.multiplyUnsafe(m).add(c.multiplyUnsafe(n.neg(w))),{x:P,y:M}=E.toAffine();return!(E.is0()||!Po(M)||P!==l)}catch{return!1}}function xA(e,t){if(t===void 0)return _A;let r=of(e),i=bi(l0("TapTweak",r,t));if(!Ut.Fn.isValid(i))throw new Error("invalid TapTweak hash");return i}function gy(e){let t=Ut.fromBytes(e.commitments[0]);return Po(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ut.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,i])=>[r,Ut.fromBytes(i).negate().toBytes()]))}}function EA(e,t){let r=Ut.fromBytes(t.commitments[0]);if(Po(r.y))return e;let i=Ut.Fn;return{...e,signingShare:i.toBytes(i.neg(i.fromBytes(e.signingShare)))}}function oX(e,t){if(Po(e.y))return t;let r=Ut.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function aX(e,t,r){let i=Ut.Fn,n=EA(e,t),o=gy(t),a=xA(Ut.fromBytes(o.commitments[0]),r),s=i.toBytes(i.add(i.fromBytes(n.signingShare),a));return{identifier:n.identifier,signingShare:s}}function sX(e,t){let r=gy(e),i=xA(Ut.fromBytes(r.commitments[0]),t),n=Ut.BASE.multiply(i),o=r.commitments.map((s,u)=>(u===0?Ut.fromBytes(s).add(n):Ut.fromBytes(s)).toBytes()),a={};for(let s in r.verifyingShares)a[s]=Ut.fromBytes(r.verifyingShares[s]).add(n).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:a}}var bp,$$,_A,hy,Ta,Ut,J$,mA,of,Po,Gc,eX,tX,rX,bA,iX,py,nX,uX,d0=Xr(()=>{v();sp();gs();vp();fA();sA();jc();vA();Ju();bp={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},$$={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_A=BigInt(0),hy=BigInt(2);Ta=Fc(bp.p,{sqrt:X$}),Ut=lA(bp,{Fp:Ta,endo:$$}),J$=gA(Ut,bs),mA={};of=e=>e.toBytes(!0).slice(1),Po=e=>e%hy===_A;Gc=bi;eX=Object.freeze({lift_x:_p}),tX=(()=>{let r=i=>(i=i===void 0?i0(48):i,Hc(i,bp.n));return Object.freeze({keygen:gp(r,yA),getPublicKey:yA,sign:Q$,verify:SA,Point:Ut,utils:Object.freeze({randomSecretKey:r,taggedHash:l0,lift_x:_p,pointToBytes:of}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),rX=oA(Ta,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),iX=()=>bA||(bA=dA(Ta,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Ta.create(BigInt("-11"))})),py=aA(Ut,e=>{let{x:t,y:r}=iX()(Ta.create(e[0]));return rX(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Ta.ORDER,m:1,k:128,expand:"xmd",hash:bs}),nX=oy({name:"FROST-secp256k1-SHA256-v1",Point:Ut,hashToScalar:py.hashToScalar,hash:bs});uX=oy({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ut,hashToScalar:py.hashToScalar,hash:bs,parsePublicKey(e){if(e.length===32)return _p(bi(e));if(e.length===33)return Ut.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ut.BASE.multiply(e);return Po(t.y)?e:Ut.Fn.neg(e)},adjustPoint:e=>Po(e.y)?e:e.negate(),challenge(e,t,r){return dy(of(e),of(t),r)},adjustNonces:oX,adjustGroupCommitmentShare:(e,t)=>Po(e.y)?t:t.negate(),adjustPublic:gy,adjustSecret:EA,adjustTx:{encode:e=>e.subarray(1),decode:e=>kt(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:sX(e.public,t),secret:aX(e.secret,e.public,t)}}})});var vn=k((u2e,PA)=>{"use strict";v();var IA=fr(),{secp256k1:fX}=(d0(),ho(h0)),g0=fX.Point,wp=g0.Fn.ORDER;function cX(e){return BigInt("0x"+(e.toString(16)||"0"))}function vy(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new IA(t,16)}function Sp(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return cX(e);throw new Error("Invalid Point")}function p0(e){var t=Object.create(Ft.prototype);return t._p=e,t}function OA(e,t){var r=Sp(t).toString(16).padStart(64,"0");return g0.fromHex((e?"03":"02")+r)}function AA(e,t){var r;try{r=OA((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function Ft(e,t,r){if(!(this instanceof Ft))return new Ft(e,t,r);var i,n;try{i=Sp(e),n=Sp(t)}catch{throw new Error("Invalid Point")}AA(i,n);try{this._p=g0.fromAffine({x:i,y:n})}catch{throw new Error("Invalid Point")}return this}Ft.fromX=function(t,r){try{var i=p0(OA(t,r))}catch{throw new Error("Invalid X")}return i.validate(),i};Ft.getG=function(){return p0(g0.BASE)};Ft.getN=function(){return vy(wp)};Ft.prototype.getX=function(){return vy(this._p.toAffine().x)};Ft.prototype.getY=function(){return vy(this._p.toAffine().y)};Object.defineProperty(Ft.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(Ft.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});Ft.prototype.mul=function(t){var r=(Sp(t)%wp+wp)%wp;return r===0n||this._p.is0()?p0(g0.ZERO):p0(this._p.multiply(r))};Ft.prototype.add=function(t){return p0(this._p.add(t._p))};Ft.prototype.mulAdd=function(t,r,i){return this.mul(t).add(r.mul(i))};Ft.prototype.eq=function(t){return this._p.equals(t._p)};Ft.prototype.isInfinity=function(){return this._p.is0()};Ft.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return AA(t.x,t.y),this};Ft.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),i=t.getY().toBuffer({size:32}),n,o=i[i.length-1]%2;return o?n=h.Buffer.from([3]):n=h.Buffer.from([2]),h.Buffer.concat([n,r])};Ft.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var i=IA.fromBuffer(e.slice(1,33));return Ft.fromX(r,i)};Ft.prototype.toBuffer=function(){return Ft.pointToCompressed(this)};Ft.prototype.toHex=function(){return this.toBuffer().toString("hex")};Ft.fromBuffer=function(e){return Ft.pointFromCompressed(e)};Ft.fromHex=function(e){return Ft.fromBuffer(h.Buffer.from(e,"hex"))};PA.exports=Ft});var pi=k((c2e,RA)=>{"use strict";v();var kA=Et(),lX=Bt(),TA=function(t){return kA.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};RA.exports={isValidJSON:function(t){var r;if(!kA.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:TA,isHexaString:TA,defineImmutable:function(t,r){return Object.keys(r).forEach(function(i){Object.defineProperty(t,i,{configurable:!1,enumerable:!0,value:r[i]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){lX.checkArgumentType(t,"number","integer");let r=h.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var Vr=k((h2e,MA)=>{"use strict";v();var af=fr(),hX=Et(),_i=Bt(),dX=pi(),yt=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof af)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};yt.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};yt.fromCompact=function(e){_i.checkArgument(h.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new yt,r=!0,i=e.slice(0,1)[0]-27-4;i<0&&(r=!1,i=i+4);var n=e.slice(1,33),o=e.slice(33,65);return _i.checkArgument(i===0||i===1||i===2||i===3,new Error("i must be 0, 1, 2, or 3")),_i.checkArgument(n.length===32,new Error("r must be 32 bytes")),_i.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=i,t.r=af.fromBuffer(n),t.s=af.fromBuffer(o),t};yt.fromDER=yt.fromBuffer=function(e,t){var r=yt.parseDER(e,t),i=new yt;return i.r=r.r,i.s=r.s,i};yt.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),i=yt.fromDER(r,!1);return i.nhashtype=t,i};yt.fromString=function(e){var t=h.Buffer.from(e,"hex");return yt.fromDER(t)};function BA(e,t){_i.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),_i.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),_i.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}yt.parseDER=function(e,t){_i.checkArgument(h.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),hX.isUndefined(t)&&(t=!0);var r=e[0];_i.checkArgument(r===48,new Error("Header byte should be 0x30"));var i=e[1],n=e.slice(2).length;_i.checkArgument(!t||i===n,new Error("Length byte should length of what follows")),i=i<n?i:n;var o=e[2];_i.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var a=e[3],s=e.slice(4,4+a),u=af.fromBuffer(s),c=e[4]===0;_i.checkArgument(a===s.length,new Error("Length of r incorrect"));var l=e[4+a+0];_i.checkArgument(l===2,new Error("Integer byte for s should be 0x02"));var m=e[4+a+1],w=e.slice(4+a+2,4+a+2+m),E=af.fromBuffer(w),P=e[4+a+2]===0;_i.checkArgument(m===w.length,new Error("Length of s incorrect"));var M=4+a+2+m;_i.checkArgument(i===M-2,new Error("Length of signature incorrect")),t&&(BA("r",s),BA("s",w));var D={header:r,length:i,rheader:o,rlength:a,rneg:c,rbuf:s,r:u,sheader:l,slength:m,sneg:P,sbuf:w,s:E};return D};yt.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var i=h.Buffer.from([r]),n=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return h.Buffer.concat([i,n,o])};yt.prototype.toBuffer=yt.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),i=!!(t[0]&128),n=r?h.Buffer.concat([h.Buffer.from([0]),e]):e,o=i?h.Buffer.concat([h.Buffer.from([0]),t]):t,a=n.length,s=o.length,u=2+a+2+s,c=2,l=2,m=48,w=h.Buffer.concat([h.Buffer.from([m,u,c,a]),n,h.Buffer.from([l,s]),o]);return w};yt.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};yt.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var i=e.slice(4);if(e[2]!==2||t===0||i[0]&128||t>1&&i[0]===0&&!(i[1]&128))return!1;var n=e.slice(6+t);return!(e[6+t-2]!==2||r===0||n[0]&128||r>1&&n[0]===0&&!(n[1]&128))};yt.prototype.hasLowS=function(){return!(this.s.lt(new af(1))||this.s.gt(new af("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};yt.prototype.hasDefinedHashtype=function(){if(!dX.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<yt.SIGHASH_ALL||e>yt.SIGHASH_SINGLE)};yt.prototype.toTxFormat=function(){var e=this.toDER(),t=h.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),h.Buffer.concat([e,t])};yt.SIGHASH_ALL=1;yt.SIGHASH_NONE=2;yt.SIGHASH_SINGLE=3;yt.SIGHASH_FORKID=64;yt.SIGHASH_ANYONECANPAY=128;yt.prototype.isCanonical=function(){var e=vn(),t=e.getN().shrn(1);return this.s.lte(t)};yt.prototype.toCanonical=function(){if(this.isCanonical())return new yt({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=vn(),t=e.getN(),r=t.sub(this.s);return new yt({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};yt.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=vn(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};yt.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};yt.prototype.applySecurityPatches=function(){var e=vn(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};MA.exports=yt});var jn=k(Ht=>{"use strict";v();var pX=Rn(),gX=Te();Ht.inherits=gX;function vX(e,t){return(e.charCodeAt(t)&64512)!==55296||t<0||t+1>=e.length?!1:(e.charCodeAt(t+1)&64512)===56320}function mX(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if(typeof e=="string")if(t){if(t==="hex")for(e=e.replace(/[^a-z0-9]+/ig,""),e.length%2!==0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16))}else for(var i=0,n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?r[i++]=o:o<2048?(r[i++]=o>>6|192,r[i++]=o&63|128):vX(e,n)?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=o&63|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=o&63|128)}else for(n=0;n<e.length;n++)r[n]=e[n]|0;return r}Ht.toArray=mX;function yX(e){for(var t="",r=0;r<e.length;r++)t+=NA(e[r].toString(16));return t}Ht.toHex=yX;function CA(e){var t=e>>>24|e>>>8&65280|e<<8&16711680|(e&255)<<24;return t>>>0}Ht.htonl=CA;function bX(e,t){for(var r="",i=0;i<e.length;i++){var n=e[i];t==="little"&&(n=CA(n)),r+=DA(n.toString(16))}return r}Ht.toHex32=bX;function NA(e){return e.length===1?"0"+e:e}Ht.zero2=NA;function DA(e){return e.length===7?"0"+e:e.length===6?"00"+e:e.length===5?"000"+e:e.length===4?"0000"+e:e.length===3?"00000"+e:e.length===2?"000000"+e:e.length===1?"0000000"+e:e}Ht.zero8=DA;function _X(e,t,r,i){var n=r-t;pX(n%4===0);for(var o=new Array(n/4),a=0,s=t;a<o.length;a++,s+=4){var u;i==="big"?u=e[s]<<24|e[s+1]<<16|e[s+2]<<8|e[s+3]:u=e[s+3]<<24|e[s+2]<<16|e[s+1]<<8|e[s],o[a]=u>>>0}return o}Ht.join32=_X;function wX(e,t){for(var r=new Array(e.length*4),i=0,n=0;i<e.length;i++,n+=4){var o=e[i];t==="big"?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=o&255):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=o&255)}return r}Ht.split32=wX;function SX(e,t){return e>>>t|e<<32-t}Ht.rotr32=SX;function xX(e,t){return e<<t|e>>>32-t}Ht.rotl32=xX;function EX(e,t){return e+t>>>0}Ht.sum32=EX;function IX(e,t,r){return e+t+r>>>0}Ht.sum32_3=IX;function OX(e,t,r,i){return e+t+r+i>>>0}Ht.sum32_4=OX;function AX(e,t,r,i,n){return e+t+r+i+n>>>0}Ht.sum32_5=AX;function PX(e,t,r,i){var n=e[t],o=e[t+1],a=i+o>>>0,s=(a<i?1:0)+r+n;e[t]=s>>>0,e[t+1]=a}Ht.sum64=PX;function TX(e,t,r,i){var n=t+i>>>0,o=(n<t?1:0)+e+r;return o>>>0}Ht.sum64_hi=TX;function kX(e,t,r,i){var n=t+i;return n>>>0}Ht.sum64_lo=kX;function RX(e,t,r,i,n,o,a,s){var u=0,c=t;c=c+i>>>0,u+=c<t?1:0,c=c+o>>>0,u+=c<o?1:0,c=c+s>>>0,u+=c<s?1:0;var l=e+r+n+a+u;return l>>>0}Ht.sum64_4_hi=RX;function BX(e,t,r,i,n,o,a,s){var u=t+i+o+s;return u>>>0}Ht.sum64_4_lo=BX;function MX(e,t,r,i,n,o,a,s,u,c){var l=0,m=t;m=m+i>>>0,l+=m<t?1:0,m=m+o>>>0,l+=m<o?1:0,m=m+s>>>0,l+=m<s?1:0,m=m+c>>>0,l+=m<c?1:0;var w=e+r+n+a+u+l;return w>>>0}Ht.sum64_5_hi=MX;function CX(e,t,r,i,n,o,a,s,u,c){var l=t+i+o+s+c;return l>>>0}Ht.sum64_5_lo=CX;function NX(e,t,r){var i=t<<32-r|e>>>r;return i>>>0}Ht.rotr64_hi=NX;function DX(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}Ht.rotr64_lo=DX;function LX(e,t,r){return e>>>r}Ht.shr64_hi=LX;function qX(e,t,r){var i=e<<32-r|t>>>r;return i>>>0}Ht.shr64_lo=qX});var Zc=k(qA=>{"use strict";v();var LA=jn(),UX=Rn();function xp(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}qA.BlockHash=xp;xp.prototype.update=function(t,r){if(t=LA.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var i=t.length%this._delta8;this.pending=t.slice(t.length-i,t.length),this.pending.length===0&&(this.pending=null),t=LA.join32(t,0,t.length-i,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this};xp.prototype.digest=function(t){return this.update(this._pad()),UX(this.pending===null),this._digest(t)};xp.prototype._pad=function(){var t=this.pendingTotal,r=this._delta8,i=r-(t+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var o=1;o<i;o++)n[o]=0;if(t<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)n[o++]=0;n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=t>>>24&255,n[o++]=t>>>16&255,n[o++]=t>>>8&255,n[o++]=t&255}else for(n[o++]=t&255,n[o++]=t>>>8&255,n[o++]=t>>>16&255,n[o++]=t>>>24&255,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,a=8;a<this.padLength;a++)n[o++]=0;return n}});var my=k(ka=>{"use strict";v();var FX=jn(),To=FX.rotr32;function HX(e,t,r,i){if(e===0)return UA(t,r,i);if(e===1||e===3)return HA(t,r,i);if(e===2)return FA(t,r,i)}ka.ft_1=HX;function UA(e,t,r){return e&t^~e&r}ka.ch32=UA;function FA(e,t,r){return e&t^e&r^t&r}ka.maj32=FA;function HA(e,t,r){return e^t^r}ka.p32=HA;function jX(e){return To(e,2)^To(e,13)^To(e,22)}ka.s0_256=jX;function zX(e){return To(e,6)^To(e,11)^To(e,25)}ka.s1_256=zX;function KX(e){return To(e,7)^To(e,18)^e>>>3}ka.g0_256=KX;function VX(e){return To(e,17)^To(e,19)^e>>>10}ka.g1_256=VX});var KA=k((_2e,zA)=>{"use strict";v();var Wc=jn(),GX=Zc(),ZX=my(),yy=Wc.rotl32,v0=Wc.sum32,WX=Wc.sum32_5,YX=ZX.ft_1,jA=GX.BlockHash,$X=[1518500249,1859775393,2400959708,3395469782];function ko(){if(!(this instanceof ko))return new ko;jA.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Wc.inherits(ko,jA);zA.exports=ko;ko.blockSize=512;ko.outSize=160;ko.hmacStrength=80;ko.padLength=64;ko.prototype._update=function(t,r){for(var i=this.W,n=0;n<16;n++)i[n]=t[r+n];for(;n<i.length;n++)i[n]=yy(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var o=this.h[0],a=this.h[1],s=this.h[2],u=this.h[3],c=this.h[4];for(n=0;n<i.length;n++){var l=~~(n/20),m=WX(yy(o,5),YX(l,a,s,u),c,i[n],$X[l]);c=u,u=s,s=yy(a,30),a=o,o=m}this.h[0]=v0(this.h[0],o),this.h[1]=v0(this.h[1],a),this.h[2]=v0(this.h[2],s),this.h[3]=v0(this.h[3],u),this.h[4]=v0(this.h[4],c)};ko.prototype._digest=function(t){return t==="hex"?Wc.toHex32(this.h,"big"):Wc.split32(this.h,"big")}});var by=k((S2e,GA)=>{"use strict";v();var Yc=jn(),XX=Zc(),$c=my(),JX=Rn(),zn=Yc.sum32,QX=Yc.sum32_4,eJ=Yc.sum32_5,tJ=$c.ch32,rJ=$c.maj32,iJ=$c.s0_256,nJ=$c.s1_256,oJ=$c.g0_256,aJ=$c.g1_256,VA=XX.BlockHash,sJ=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Ro(){if(!(this instanceof Ro))return new Ro;VA.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sJ,this.W=new Array(64)}Yc.inherits(Ro,VA);GA.exports=Ro;Ro.blockSize=512;Ro.outSize=256;Ro.hmacStrength=192;Ro.padLength=64;Ro.prototype._update=function(t,r){for(var i=this.W,n=0;n<16;n++)i[n]=t[r+n];for(;n<i.length;n++)i[n]=QX(aJ(i[n-2]),i[n-7],oJ(i[n-15]),i[n-16]);var o=this.h[0],a=this.h[1],s=this.h[2],u=this.h[3],c=this.h[4],l=this.h[5],m=this.h[6],w=this.h[7];for(JX(this.k.length===i.length),n=0;n<i.length;n++){var E=eJ(w,nJ(c),tJ(c,l,m),this.k[n],i[n]),P=zn(iJ(o),rJ(o,a,s));w=m,m=l,l=c,c=zn(u,E),u=s,s=a,a=o,o=zn(E,P)}this.h[0]=zn(this.h[0],o),this.h[1]=zn(this.h[1],a),this.h[2]=zn(this.h[2],s),this.h[3]=zn(this.h[3],u),this.h[4]=zn(this.h[4],c),this.h[5]=zn(this.h[5],l),this.h[6]=zn(this.h[6],m),this.h[7]=zn(this.h[7],w)};Ro.prototype._digest=function(t){return t==="hex"?Yc.toHex32(this.h,"big"):Yc.split32(this.h,"big")}});var YA=k((E2e,WA)=>{"use strict";v();var _y=jn(),ZA=by();function Ra(){if(!(this instanceof Ra))return new Ra;ZA.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}_y.inherits(Ra,ZA);WA.exports=Ra;Ra.blockSize=512;Ra.outSize=224;Ra.hmacStrength=192;Ra.padLength=64;Ra.prototype._digest=function(t){return t==="hex"?_y.toHex32(this.h.slice(0,7),"big"):_y.split32(this.h.slice(0,7),"big")}});var xy=k((O2e,QA)=>{"use strict";v();var Ri=jn(),uJ=Zc(),fJ=Rn(),Bo=Ri.rotr64_hi,Mo=Ri.rotr64_lo,$A=Ri.shr64_hi,XA=Ri.shr64_lo,_s=Ri.sum64,wy=Ri.sum64_hi,Sy=Ri.sum64_lo,cJ=Ri.sum64_4_hi,lJ=Ri.sum64_4_lo,hJ=Ri.sum64_5_hi,dJ=Ri.sum64_5_lo,JA=uJ.BlockHash,pJ=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Kn(){if(!(this instanceof Kn))return new Kn;JA.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=pJ,this.W=new Array(160)}Ri.inherits(Kn,JA);QA.exports=Kn;Kn.blockSize=1024;Kn.outSize=512;Kn.hmacStrength=192;Kn.padLength=128;Kn.prototype._prepareBlock=function(t,r){for(var i=this.W,n=0;n<32;n++)i[n]=t[r+n];for(;n<i.length;n+=2){var o=IJ(i[n-4],i[n-3]),a=OJ(i[n-4],i[n-3]),s=i[n-14],u=i[n-13],c=xJ(i[n-30],i[n-29]),l=EJ(i[n-30],i[n-29]),m=i[n-32],w=i[n-31];i[n]=cJ(o,a,s,u,c,l,m,w),i[n+1]=lJ(o,a,s,u,c,l,m,w)}};Kn.prototype._update=function(t,r){this._prepareBlock(t,r);var i=this.W,n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],u=this.h[4],c=this.h[5],l=this.h[6],m=this.h[7],w=this.h[8],E=this.h[9],P=this.h[10],M=this.h[11],D=this.h[12],L=this.h[13],U=this.h[14],K=this.h[15];fJ(this.k.length===i.length);for(var C=0;C<i.length;C+=2){var N=U,F=K,H=wJ(w,E),z=SJ(w,E),V=gJ(w,E,P,M,D,L),B=vJ(w,E,P,M,D,L),g=this.k[C],I=this.k[C+1],y=i[C],f=i[C+1],p=hJ(N,F,H,z,V,B,g,I,y,f),_=dJ(N,F,H,z,V,B,g,I,y,f);N=bJ(n,o),F=_J(n,o),H=mJ(n,o,a,s,u,c),z=yJ(n,o,a,s,u,c);var x=wy(N,F,H,z),b=Sy(N,F,H,z);U=D,K=L,D=P,L=M,P=w,M=E,w=wy(l,m,p,_),E=Sy(m,m,p,_),l=u,m=c,u=a,c=s,a=n,s=o,n=wy(p,_,x,b),o=Sy(p,_,x,b)}_s(this.h,0,n,o),_s(this.h,2,a,s),_s(this.h,4,u,c),_s(this.h,6,l,m),_s(this.h,8,w,E),_s(this.h,10,P,M),_s(this.h,12,D,L),_s(this.h,14,U,K)};Kn.prototype._digest=function(t){return t==="hex"?Ri.toHex32(this.h,"big"):Ri.split32(this.h,"big")};function gJ(e,t,r,i,n){var o=e&r^~e&n;return o<0&&(o+=4294967296),o}function vJ(e,t,r,i,n,o){var a=t&i^~t&o;return a<0&&(a+=4294967296),a}function mJ(e,t,r,i,n){var o=e&r^e&n^r&n;return o<0&&(o+=4294967296),o}function yJ(e,t,r,i,n,o){var a=t&i^t&o^i&o;return a<0&&(a+=4294967296),a}function bJ(e,t){var r=Bo(e,t,28),i=Bo(t,e,2),n=Bo(t,e,7),o=r^i^n;return o<0&&(o+=4294967296),o}function _J(e,t){var r=Mo(e,t,28),i=Mo(t,e,2),n=Mo(t,e,7),o=r^i^n;return o<0&&(o+=4294967296),o}function wJ(e,t){var r=Bo(e,t,14),i=Bo(e,t,18),n=Bo(t,e,9),o=r^i^n;return o<0&&(o+=4294967296),o}function SJ(e,t){var r=Mo(e,t,14),i=Mo(e,t,18),n=Mo(t,e,9),o=r^i^n;return o<0&&(o+=4294967296),o}function xJ(e,t){var r=Bo(e,t,1),i=Bo(e,t,8),n=$A(e,t,7),o=r^i^n;return o<0&&(o+=4294967296),o}function EJ(e,t){var r=Mo(e,t,1),i=Mo(e,t,8),n=XA(e,t,7),o=r^i^n;return o<0&&(o+=4294967296),o}function IJ(e,t){var r=Bo(e,t,19),i=Bo(t,e,29),n=$A(e,t,6),o=r^i^n;return o<0&&(o+=4294967296),o}function OJ(e,t){var r=Mo(e,t,19),i=Mo(t,e,29),n=XA(e,t,6),o=r^i^n;return o<0&&(o+=4294967296),o}});var rP=k((P2e,tP)=>{"use strict";v();var Ey=jn(),eP=xy();function Ba(){if(!(this instanceof Ba))return new Ba;eP.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ey.inherits(Ba,eP);tP.exports=Ba;Ba.blockSize=1024;Ba.outSize=384;Ba.hmacStrength=192;Ba.padLength=128;Ba.prototype._digest=function(t){return t==="hex"?Ey.toHex32(this.h.slice(0,12),"big"):Ey.split32(this.h.slice(0,12),"big")}});var iP=k(Xc=>{"use strict";v();Xc.sha1=KA();Xc.sha224=YA();Xc.sha256=by();Xc.sha384=rP();Xc.sha512=xy()});var fP=k(uP=>{"use strict";v();var sf=jn(),AJ=Zc(),Ep=sf.rotl32,nP=sf.sum32,m0=sf.sum32_3,oP=sf.sum32_4,sP=AJ.BlockHash;function Co(){if(!(this instanceof Co))return new Co;sP.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}sf.inherits(Co,sP);uP.ripemd160=Co;Co.blockSize=512;Co.outSize=160;Co.hmacStrength=192;Co.padLength=64;Co.prototype._update=function(t,r){for(var i=this.h[0],n=this.h[1],o=this.h[2],a=this.h[3],s=this.h[4],u=i,c=n,l=o,m=a,w=s,E=0;E<80;E++){var P=nP(Ep(oP(i,aP(E,n,o,a),t[kJ[E]+r],PJ(E)),BJ[E]),s);i=s,s=a,a=Ep(o,10),o=n,n=P,P=nP(Ep(oP(u,aP(79-E,c,l,m),t[RJ[E]+r],TJ(E)),MJ[E]),w),u=w,w=m,m=Ep(l,10),l=c,c=P}P=m0(this.h[1],o,m),this.h[1]=m0(this.h[2],a,w),this.h[2]=m0(this.h[3],s,u),this.h[3]=m0(this.h[4],i,c),this.h[4]=m0(this.h[0],n,l),this.h[0]=P};Co.prototype._digest=function(t){return t==="hex"?sf.toHex32(this.h,"little"):sf.split32(this.h,"little")};function aP(e,t,r,i){return e<=15?t^r^i:e<=31?t&r|~t&i:e<=47?(t|~r)^i:e<=63?t&i|r&~i:t^(r|~i)}function PJ(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function TJ(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}var kJ=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],RJ=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],BJ=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],MJ=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var lP=k((C2e,cP)=>{"use strict";v();var CJ=jn(),NJ=Rn();function Jc(e,t,r){if(!(this instanceof Jc))return new Jc(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(CJ.toArray(t,r))}cP.exports=Jc;Jc.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),NJ(t.length<=this.blockSize);for(var r=t.length;r<this.blockSize;r++)t.push(0);for(r=0;r<t.length;r++)t[r]^=54;for(this.inner=new this.Hash().update(t),r=0;r<t.length;r++)t[r]^=106;this.outer=new this.Hash().update(t)};Jc.prototype.update=function(t,r){return this.inner.update(t,r),this};Jc.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}});var dP=k(hP=>{v();var ri=hP;ri.utils=jn();ri.common=Zc();ri.sha=iP();ri.ripemd=fP();ri.hmac=lP();ri.sha1=ri.sha.sha1;ri.sha256=ri.sha.sha256;ri.sha224=ri.sha.sha224;ri.sha384=ri.sha.sha384;ri.sha512=ri.sha.sha512;ri.ripemd160=ri.ripemd.ripemd160});var gP=k((q2e,pP)=>{"use strict";v();var Ip=dP(),Ma=Bt(),Sr=pP.exports;Sr.sha1=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha1().update(e).digest("hex"),"hex")};Sr.sha1.blocksize=512;Sr.sha256=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha256().update(e).digest("hex"),"hex")};Sr.sha256.blocksize=512;Sr.sha256sha256=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),Sr.sha256(Sr.sha256(e))};Sr.ripemd160=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.ripemd160().update(e).digest("hex"),"hex")};Sr.sha256ripemd160=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),Sr.ripemd160(Sr.sha256(e))};Sr.sha512=function(e){return Ma.checkArgument(h.Buffer.isBuffer(e)),h.Buffer.from(Ip.sha512().update(e).digest("hex"),"hex")};Sr.sha512.blocksize=1024;Sr.hmac=function(e,t,r){Ma.checkArgument(h.Buffer.isBuffer(t)),Ma.checkArgument(h.Buffer.isBuffer(r)),Ma.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=h.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=h.Buffer.alloc(i);o.fill(92);var a=h.Buffer.alloc(i);a.fill(54);for(var s=h.Buffer.alloc(i),u=h.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(h.Buffer.concat([s,e(h.Buffer.concat([u,t]))]))};Sr.sha256hmac=function(e,t){return Sr.hmac(Sr.sha256,e,t)};Sr.sha512hmac=function(e,t){return Sr.hmac(Sr.sha512,e,t)}});var mP=k((F2e,vP)=>{"use strict";v();var Op=_r(),Ca=Bt(),xr=vP.exports;xr.sha1=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha1").update(e).digest()};xr.sha1.blocksize=512;xr.sha256=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha256").update(e).digest()};xr.sha256.blocksize=512;xr.sha256sha256=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),xr.sha256(xr.sha256(e))};xr.ripemd160=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("ripemd160").update(e).digest()};xr.sha256ripemd160=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),xr.ripemd160(xr.sha256(e))};xr.sha512=function(e){return Ca.checkArgument(h.Buffer.isBuffer(e)),Op.createHash("sha512").update(e).digest()};xr.sha512.blocksize=1024;xr.hmac=function(e,t,r){Ca.checkArgument(h.Buffer.isBuffer(t)),Ca.checkArgument(h.Buffer.isBuffer(r)),Ca.checkArgument(e.blocksize);var i=e.blocksize/8;if(r.length>i)r=e(r);else if(r.length<i){var n=h.Buffer.alloc(i);n.fill(0),r.copy(n),r=n}var o=h.Buffer.alloc(i);o.fill(92);var a=h.Buffer.alloc(i);a.fill(54);for(var s=h.Buffer.alloc(i),u=h.Buffer.alloc(i),c=0;c<i;c++)s[c]=o[c]^r[c],u[c]=a[c]^r[c];return e(h.Buffer.concat([s,e(h.Buffer.concat([u,t]))]))};xr.sha256hmac=function(e,t){return xr.hmac(xr.sha256,e,t)};xr.sha512hmac=function(e,t){return xr.hmac(xr.sha512,e,t)}});var cr=k((j2e,Iy)=>{v();A.default.browser?Iy.exports=gP():Iy.exports=mP()});var xs=k((K2e,_P)=>{"use strict";v();var Na=Et(),y0=pi(),uf=[],b0={};function yP(){}yP.prototype.toString=function(){return this.name};function _0(e,t){if(~uf.indexOf(e))return e;if(t){Na.isArray(t)||(t=[t]);for(var r=0;r<uf.length;r++){var i=uf[r],n=Na.pick(i,t),o=Na.values(n);if(~o.indexOf(e))return i}return}return b0[e]}function Ap(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function w0(e){var t=new yP;y0.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Na.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:Ap(e.cashAddrPrefix)}),e.networkMagic&&Na.extend(t,{networkMagic:y0.integerAsBuffer(e.networkMagic)}),e.port&&Na.extend(t,{port:e.port}),e.dnsSeeds&&Na.extend(t,{dnsSeeds:e.dnsSeeds}),uf.push(t),DJ(t,r),t}function DJ(e,t){for(var r=0;r<t.length;r++){var i=t[r],n=e[i];!Na.isUndefined(n)&&!Na.isObject(n)&&(b0[n]=e)}}function LJ(e,t){for(var r=0;r<t.length;r++){var i=t[r];b0[i]===e&&delete b0[i]}}function qJ(e){for(var t=0;t<uf.length;t++)uf[t]===e&&uf.splice(t,1);LJ(e,Object.keys(b0))}var Pp={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},bP=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],ws={PORT:18333,NETWORK_MAGIC:Pp.testnet,DNS_SEEDS:bP,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Da={PORT:18444,NETWORK_MAGIC:Pp.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},Ss={PORT:9333,NETWORK_MAGIC:Pp.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},UJ={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:Pp.livenet,port:8333,dnsSeeds:bP},FJ={name:"testnet",prefix:ws.PREFIX,cashAddrPrefix:ws.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ws.NETWORK_MAGIC},HJ={name:"regtest",prefix:Da.PREFIX,cashAddrPrefix:Da.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Da.NETWORK_MAGIC,port:Da.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},jJ={name:"stn",prefix:Ss.PREFIX,cashAddrPrefix:Ss.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ss.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};w0(FJ);w0(jJ);w0(HJ);w0(UJ);var Oy=_0("livenet"),zJ=_0("regtest"),No=_0("testnet"),KJ=_0("stn");Object.defineProperty(No,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Da.PORT:this.stnEnabled?Ss.PORT:ws.PORT}});Object.defineProperty(No,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y0.integerAsBuffer(Da.NETWORK_MAGIC):this.stnEnabled?y0.integerAsBuffer(Ss.NETWORK_MAGIC):y0.integerAsBuffer(ws.NETWORK_MAGIC)}});Object.defineProperty(No,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Da.DNS_SEEDS:this.stnEnabled?Ss.DNS_SEEDS:ws.DNS_SEEDS}});Object.defineProperty(No,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Da.CASHADDRPREFIX:this.stnEnabled?Ss.CASHADDRPREFIX:ws.CASHADDRPREFIX}});Object.defineProperty(No,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ap(Da.CASHADDRPREFIX):this.stnEnabled?Ap(Ss.CASHADDRPREFIX):Ap(ws.CASHADDRPREFIX)}});function VJ(){No.regtestEnabled=!0}function GJ(){No.regtestEnabled=!1}function ZJ(){No.stnEnabled=!0}function WJ(){No.stnEnabled=!1}_P.exports={add:w0,remove:qJ,defaultNetwork:Oy,livenet:Oy,mainnet:Oy,testnet:No,regtest:zJ,stn:KJ,get:_0,enableRegtest:VJ,disableRegtest:GJ,enableStn:ZJ,disableStn:WJ}});var S0=k((G2e,xP)=>{"use strict";v();var Ay=Et(),wP=Z2(),SP=Kt(),YJ="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),Gr=function e(t){if(!(this instanceof e))return new e(t);if(h.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};Gr.validCharacters=function(t){return SP.Buffer.isBuffer(t)&&(t=t.toString()),Ay.every(Ay.map(t,function(r){return Ay.includes(YJ,r)}))};Gr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Gr.encode=function(e){if(!SP.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return wP.encode(e)};Gr.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return h.Buffer.from(wP.decode(e))};Gr.prototype.fromBuffer=function(e){return this.buf=e,this};Gr.fromBuffer=function(e){return new Gr().fromBuffer(e)};Gr.fromHex=function(e){return Gr.fromBuffer(h.Buffer.from(e,"hex"))};Gr.prototype.fromString=function(e){var t=Gr.decode(e);return this.buf=t,this};Gr.fromString=function(e){return new Gr().fromString(e)};Gr.prototype.toBuffer=function(){return this.buf};Gr.prototype.toHex=function(){return this.toBuffer().toString("hex")};Gr.prototype.toString=function(){return Gr.encode(this.buf)};xP.exports=Gr});var Qc=k((W2e,AP)=>{"use strict";v();var EP=Et(),Tp=S0(),IP=Kt(),OP=cr().sha256sha256,lr=function e(t){if(!(this instanceof e))return new e(t);if(h.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var i=t;this.fromString(i)}};lr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};lr.validChecksum=function(t,r){return EP.isString(t)&&(t=IP.Buffer.from(Tp.decode(t))),EP.isString(r)&&(r=IP.Buffer.from(Tp.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),lr.checksum(t).toString("hex")===r.toString("hex")};lr.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=h.Buffer.from(Tp.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),i=t.slice(-4),n=OP(r),o=n.slice(0,4);if(i.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};lr.checksum=function(e){return OP(e).slice(0,4)};lr.encode=function(e){if(!h.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=h.Buffer.alloc(e.length+4),r=lr.checksum(e);return e.copy(t),r.copy(t,e.length),Tp.encode(t)};lr.prototype.fromBuffer=function(e){return this.buf=e,this};lr.fromBuffer=function(e){return new lr().fromBuffer(e)};lr.fromHex=function(e){return lr.fromBuffer(h.Buffer.from(e,"hex"))};lr.prototype.fromString=function(e){var t=lr.decode(e);return this.buf=t,this};lr.fromString=function(e){var t=lr.decode(e);return new lr(t)};lr.prototype.toBuffer=function(){return this.buf};lr.prototype.toHex=function(){return this.toBuffer().toString("hex")};lr.prototype.toString=function(){return lr.encode(this.buf)};AP.exports=lr});var La=k(($2e,TP)=>{"use strict";v();var x0=Et(),PP=Bt(),el=fr(),gr=function e(t){if(!(this instanceof e))return new e(t);if(!x0.isUndefined(t))if(h.Buffer.isBuffer(t))this.set({buf:t});else if(x0.isString(t)){var r=h.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(x0.isObject(t)){var i=t;this.set(i)}else throw new TypeError("Unrecognized argument for BufferReader")};gr.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};gr.prototype.eof=function(){return this.pos>=this.buf.length};gr.prototype.finished=gr.prototype.eof;gr.prototype.read=function(e){PP.checkArgument(!x0.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};gr.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};gr.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};gr.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};gr.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};gr.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};gr.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};gr.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};gr.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=el.fromBuffer(e);return this.pos=this.pos+8,t};gr.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,i;if(r<=9007199254740991)i=new el(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);i=new el(n,10,"le")}return this.pos=this.pos+8,i};gr.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};gr.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return PP.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};gr.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};gr.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new el(this.readUInt16LE());case 254:return new el(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new el(e)}};gr.prototype.reverse=function(){for(var e=h.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};gr.prototype.readReverse=function(e){x0.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,h.Buffer.from(t).reverse()};TP.exports=gr});var ky=k((J2e,MP)=>{"use strict";v();function Es(e){"@babel/helpers - typeof";return Es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Es(e)}function kP(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,XJ(i.key),i)}}function $J(e,t,r){return t&&kP(e.prototype,t),r&&kP(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function XJ(e){var t=JJ(e,"string");return Es(t)==="symbol"?t:String(t)}function JJ(e,t){if(Es(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(Es(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function QJ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function eQ(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ty(e,t)}function Ty(e,t){return Ty=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},Ty(e,t)}function tQ(e){var t=nQ();return function(){var i=kp(e),n;if(t){var o=kp(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return rQ(this,n)}}function rQ(e,t){if(t&&(Es(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return iQ(e)}function iQ(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function nQ(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function kp(e){return kp=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kp(e)}var BP={},tl,Py;function E0(e,t,r){r||(r=Error);function i(o,a,s){return typeof t=="string"?t:t(o,a,s)}var n=(function(o){eQ(s,o);var a=tQ(s);function s(u,c,l){var m;return QJ(this,s),m=a.call(this,i(u,c,l)),m.code=e,m}return $J(s)})(r);BP[e]=n}function RP(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function oQ(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function aQ(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function sQ(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}E0("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);E0("ERR_INVALID_ARG_TYPE",function(e,t,r){tl===void 0&&(tl=Is()),tl(typeof e=="string","'name' must be a string");var i;typeof t=="string"&&oQ(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var n;if(aQ(e," argument"))n="The ".concat(e," ").concat(i," ").concat(RP(t,"type"));else{var o=sQ(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(o," ").concat(i," ").concat(RP(t,"type"))}return n+=". Received type ".concat(Es(r)),n},TypeError);E0("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";Py===void 0&&(Py=rn());var i=Py.inspect(t);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(i)},TypeError,RangeError);E0("ERR_INVALID_RETURN_VALUE",function(e,t,r){var i;return r&&r.constructor&&r.constructor.name?i="instance of ".concat(r.constructor.name):i="type ".concat(Es(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(i,".")},TypeError);E0("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];tl===void 0&&(tl=Is()),tl(t.length>0,"At least one arg needs to be specified");var i="The ",n=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),n){case 1:i+="".concat(t[0]," argument");break;case 2:i+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:i+=t.slice(0,n-1).join(", "),i+=", and ".concat(t[n-1]," arguments");break}return"".concat(i," must be specified")},TypeError);MP.exports.codes=BP});var zP=k((epe,jP)=>{"use strict";v();function CP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function NP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?CP(Object(r),!0).forEach(function(i){uQ(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):CP(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function uQ(e,t,r){return t=UP(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function DP(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,UP(i.key),i)}}function cQ(e,t,r){return t&&DP(e.prototype,t),r&&DP(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function UP(e){var t=lQ(e,"string");return Bi(t)==="symbol"?t:String(t)}function lQ(e,t){if(Bi(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(Bi(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function hQ(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&P0(e,t)}function dQ(e){var t=HP();return function(){var i=T0(e),n;if(t){var o=T0(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return FP(this,n)}}function FP(e,t){if(t&&(Bi(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ry(e)}function Ry(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function By(e){var t=typeof Map=="function"?new Map:void 0;return By=function(i){if(i===null||!pQ(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,n)}function n(){return Rp(i,arguments,T0(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P0(n,i)},By(e)}function Rp(e,t,r){return HP()?Rp=Reflect.construct.bind():Rp=function(n,o,a){var s=[null];s.push.apply(s,o);var u=Function.bind.apply(n,s),c=new u;return a&&P0(c,a.prototype),c},Rp.apply(null,arguments)}function HP(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function pQ(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function P0(e,t){return P0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,n){return i.__proto__=n,i},P0(e,t)}function T0(e){return T0=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},T0(e)}function Bi(e){"@babel/helpers - typeof";return Bi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bi(e)}var gQ=rn(),My=gQ.inspect,vQ=ky(),mQ=vQ.codes.ERR_INVALID_ARG_TYPE;function LP(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function yQ(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Vn="",I0="",O0="",ii="",ff={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},bQ=10;function qP(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(i){r[i]=e[i]}),Object.defineProperty(r,"message",{value:e.message}),r}function A0(e){return My(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function _Q(e,t,r){var i="",n="",o=0,a="",s=!1,u=A0(e),c=u.split(`
20
20
  `),l=A0(t).split(`