flagmint-js-sdk 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flagmint.cjs.js +1 -1
- package/dist/flagmint.es.js +4 -1
- package/dist/flagmint.umd.js +1 -1
- package/package.json +1 -1
package/dist/flagmint.cjs.js
CHANGED
|
@@ -15,4 +15,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}var Qu=Ot.Buffer,Mn=Gt.crypto||Gt.
|
|
|
15
15
|
`)},Vf}var nh;function tm(){return nh||(nh=1,function(h){var n=h;n.der=Do(),n.pem=Q2()}(Zf)),Zf}var fh;function fn(){return fh||(fh=1,function(h){var n=h;n.bignum=W2,n.define=V2().define,n.base=Ui(),n.constants=qo(),n.decoders=j2(),n.encoders=tm()}(Df)),Df}var ir=fn(),ah=ir.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),em=ir.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),V0=ir.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),rm=ir.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(V0),this.key("subjectPublicKey").bitstr())}),im=ir.define("RelativeDistinguishedName",function(){this.setof(em)}),nm=ir.define("RDNSequence",function(){this.seqof(im)}),hh=ir.define("Name",function(){this.choice({rdnSequence:this.use(nm)})}),fm=ir.define("Validity",function(){this.seq().obj(this.key("notBefore").use(ah),this.key("notAfter").use(ah))}),am=ir.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),hm=ir.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(V0),this.key("issuer").use(hh),this.key("validity").use(fm),this.key("subject").use(hh),this.key("subjectPublicKeyInfo").use(rm),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(am).optional())}),sm=ir.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(hm),this.key("signatureAlgorithm").use(V0),this.key("signatureValue").bitstr())}),om=sm,nr=fn();rr.certificate=om;var um=nr.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())});rr.RSAPrivateKey=um;var lm=nr.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});rr.RSAPublicKey=lm;var No=nr.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())}),dm=nr.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(No),this.key("subjectPublicKey").bitstr())});rr.PublicKey=dm;var cm=nr.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(No),this.key("subjectPrivateKey").octstr())});rr.PrivateKey=cm;var vm=nr.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())});rr.EncryptedPrivateKey=vm;var pm=nr.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())});rr.DSAPrivateKey=pm;rr.DSAparam=nr.define("DSAparam",function(){this.int()});var mm=nr.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),gm=nr.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(mm),this.key("publicKey").optional().explicit(1).bitstr())});rr.ECPrivateKey=gm;rr.signature=nr.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())});const bm={"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 ym=/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,wm=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,Mm=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,xm=Wn,_m=Le,pn=Ot.Buffer,Sm=function(h,n){var s=h.toString(),o=s.match(ym),m;if(o){var g="aes"+o[1],y=pn.from(o[2],"hex"),S=pn.from(o[3].replace(/[\r\n]/g,""),"base64"),B=xm(n,y.slice(0,8),parseInt(o[1],10)).key,M=[],x=_m.createDecipheriv(g,B,y);M.push(x.update(S)),M.push(x.final()),m=pn.concat(M)}else{var f=s.match(Mm);m=pn.from(f[2].replace(/[\r\n]/g,""),"base64")}var I=s.match(wm)[1];return{tag:I,data:m}},qe=rr,Am=bm,Bm=Sm,Em=Le,km=Un,c0=Ot.Buffer;function Im(h,n){var s=h.algorithm.decrypt.kde.kdeparams.salt,o=parseInt(h.algorithm.decrypt.kde.kdeparams.iters.toString(),10),m=Am[h.algorithm.decrypt.cipher.algo.join(".")],f=h.algorithm.decrypt.cipher.iv,g=h.subjectPrivateKey,y=parseInt(m.split("-")[1],10)/8,S=km.pbkdf2Sync(n,s,o,y,"sha1"),B=Em.createDecipheriv(m,S,f),M=[];return M.push(B.update(g)),M.push(B.final()),c0.concat(M)}function $o(h){var n;typeof h=="object"&&!c0.isBuffer(h)&&(n=h.passphrase,h=h.key),typeof h=="string"&&(h=c0.from(h));var s=Bm(h,n),o=s.tag,m=s.data,f,g;switch(o){case"CERTIFICATE":g=qe.certificate.decode(m,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(g||(g=qe.PublicKey.decode(m,"der")),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return qe.RSAPublicKey.decode(g.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return g.subjectPrivateKey=g.subjectPublicKey,{type:"ec",data:g};case"1.2.840.10040.4.1":return g.algorithm.params.pub_key=qe.DSAparam.decode(g.subjectPublicKey.data,"der"),{type:"dsa",data:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"ENCRYPTED PRIVATE KEY":m=qe.EncryptedPrivateKey.decode(m,"der"),m=Im(m,n);case"PRIVATE KEY":switch(g=qe.PrivateKey.decode(m,"der"),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return qe.RSAPrivateKey.decode(g.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:g.algorithm.curve,privateKey:qe.ECPrivateKey.decode(g.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return g.algorithm.params.priv_key=qe.DSAparam.decode(g.subjectPrivateKey,"der"),{type:"dsa",params:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"RSA PUBLIC KEY":return qe.RSAPublicKey.decode(m,"der");case"RSA PRIVATE KEY":return qe.RSAPrivateKey.decode(m,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:qe.DSAPrivateKey.decode(m,"der")};case"EC PRIVATE KEY":return m=qe.ECPrivateKey.decode(m,"der"),{curve:m.parameters.value,privateKey:m.privateKey};default:throw new Error("unknown key type "+o)}}$o.signature=qe.signature;var sf=$o;const Uo={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var sh;function Rm(){if(sh)return Ci.exports;sh=1;var h=Ot.Buffer,n=Vh,s=U0,o=Z0().ec,m=$0,f=sf,g=Uo,y=1;function S(z,$,lt,H,At){var Bt=f($);if(Bt.curve){if(H!=="ecdsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");return B(z,Bt)}else if(Bt.type==="dsa"){if(H!=="dsa")throw new Error("wrong private key type");return M(z,Bt,lt)}if(H!=="rsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");if($.padding!==void 0&&$.padding!==y)throw new Error("illegal or unsupported padding mode");z=h.concat([At,z]);for(var Ct=Bt.modulus.byteLength(),Et=[0,1];z.length+Et.length+1<Ct;)Et.push(255);Et.push(0);for(var Y=-1;++Y<z.length;)Et.push(z[Y]);var It=s(Et,Bt);return It}function B(z,$){var lt=g[$.curve.join(".")];if(!lt)throw new Error("unknown curve "+$.curve.join("."));var H=new o(lt),At=H.keyFromPrivate($.privateKey),Bt=At.sign(z);return h.from(Bt.toDER())}function M(z,$,lt){for(var H=$.params.priv_key,At=$.params.p,Bt=$.params.q,Ct=$.params.g,Et=new m(0),Y,It=k(z,Bt).mod(Bt),p=!1,t=I(H,Bt,z,lt);p===!1;)Y=L(Bt,t,lt),Et=W(Ct,Y,At,Bt),p=Y.invm(Bt).imul(It.add(H.mul(Et))).mod(Bt),p.cmpn(0)===0&&(p=!1,Et=new m(0));return x(Et,p)}function x(z,$){z=z.toArray(),$=$.toArray(),z[0]&128&&(z=[0].concat(z)),$[0]&128&&($=[0].concat($));var lt=z.length+$.length+4,H=[48,lt,2,z.length];return H=H.concat(z,[2,$.length],$),h.from(H)}function I(z,$,lt,H){if(z=h.from(z.toArray()),z.length<$.byteLength()){var At=h.alloc($.byteLength()-z.length);z=h.concat([At,z])}var Bt=lt.length,Ct=D(lt,$),Et=h.alloc(Bt);Et.fill(1);var Y=h.alloc(Bt);return Y=n(H,Y).update(Et).update(h.from([0])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),Y=n(H,Y).update(Et).update(h.from([1])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),{k:Y,v:Et}}function k(z,$){var lt=new m(z),H=(z.length<<3)-$.bitLength();return H>0&<.ishrn(H),lt}function D(z,$){z=k(z,$),z=z.mod($);var lt=h.from(z.toArray());if(lt.length<$.byteLength()){var H=h.alloc($.byteLength()-lt.length);lt=h.concat([H,lt])}return lt}function L(z,$,lt){var H,At;do{for(H=h.alloc(0);H.length*8<z.bitLength();)$.v=n(lt,$.k).update($.v).digest(),H=h.concat([H,$.v]);At=k(H,z),$.k=n(lt,$.k).update($.v).update(h.from([0])).digest(),$.v=n(lt,$.k).update($.v).digest()}while(At.cmp(z)!==-1);return At}function W(z,$,lt,H){return z.toRed(m.mont(lt)).redPow($).fromRed().mod(H)}return Ci.exports=S,Ci.exports.getKey=I,Ci.exports.makeKey=L,Ci.exports}var Yf,oh;function Tm(){if(oh)return Yf;oh=1;var h=Ot.Buffer,n=$0,s=Z0().ec,o=sf,m=Uo;function f(B,M,x,I,k){var D=o(x);if(D.type==="ec"){if(I!=="ecdsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");return g(B,M,D)}else if(D.type==="dsa"){if(I!=="dsa")throw new Error("wrong public key type");return y(B,M,D)}if(I!=="rsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");M=h.concat([k,M]);for(var L=D.modulus.byteLength(),W=[1],z=0;M.length+W.length+2<L;)W.push(255),z+=1;W.push(0);for(var $=-1;++$<M.length;)W.push(M[$]);W=h.from(W);var lt=n.mont(D.modulus);B=new n(B).toRed(lt),B=B.redPow(new n(D.publicExponent)),B=h.from(B.fromRed().toArray());var H=z<8?1:0;for(L=Math.min(B.length,W.length),B.length!==W.length&&(H=1),$=-1;++$<L;)H|=B[$]^W[$];return H===0}function g(B,M,x){var I=m[x.data.algorithm.curve.join(".")];if(!I)throw new Error("unknown curve "+x.data.algorithm.curve.join("."));var k=new s(I),D=x.data.subjectPrivateKey.data;return k.verify(M,B,D)}function y(B,M,x){var I=x.data.p,k=x.data.q,D=x.data.g,L=x.data.pub_key,W=o.signature.decode(B,"der"),z=W.s,$=W.r;S(z,k),S($,k);var lt=n.mont(I),H=z.invm(k),At=D.toRed(lt).redPow(new n(M).mul(H).mod(k)).fromRed().mul(L.toRed(lt).redPow($.mul(H).mod(k)).fromRed()).mod(I).mod(k);return At.cmp($)===0}function S(B,M){if(B.cmpn(0)<=0)throw new Error("invalid sig");if(B.cmp(M)>=0)throw new Error("invalid sig")}return Yf=f,Yf}var Jf,uh;function Cm(){if(uh)return Jf;uh=1;var h=Ot.Buffer,n=Gi,s=kv,o=Jt,m=Rm(),f=Tm(),g=Yh;Object.keys(g).forEach(function(x){g[x].id=h.from(g[x].id,"hex"),g[x.toLowerCase()]=g[x]});function y(x){s.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hashType=I.hash,this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}o(y,s.Writable),y.prototype._write=function(I,k,D){this._hash.update(I),D()},y.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},y.prototype.sign=function(I,k){this.end();var D=this._hash.digest(),L=m(D,I,this._hashType,this._signType,this._tag);return k?L.toString(k):L};function S(x){s.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}o(S,s.Writable),S.prototype._write=function(I,k,D){this._hash.update(I),D()},S.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},S.prototype.verify=function(I,k,D){var L=typeof k=="string"?h.from(k,D):k;this.end();var W=this._hash.digest();return f(L,W,I,this._signType,this._tag)};function B(x){return new y(x)}function M(x){return new S(x)}return Jf={Sign:B,Verify:M,createSign:B,createVerify:M},Jf}var Y0={exports:{}};Y0.exports;(function(h){(function(n,s){function o(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:s.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=De.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),o(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(o(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(o(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var u=t.length-r;for(a=u%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,u=Math.min(c,c-v)+i,e=0,l=i;l<u;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){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"],x=[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],I=[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];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],u=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-u.length]+u+i:i=u+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}o(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&o(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return o(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);o(a<=d,"byte array longer than desired length"),o(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),u,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[e]=u;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[d-e-1]=u}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return o((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return o((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return o((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){o(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){o(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,u=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=u>>>26,b=u&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,u=l|0}return u!==0?r.words[e]=u|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,u,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,Ft=a[4]|0,tt=Ft&8191,vt=Ft>>>13,Dt=a[5]|0,et=Dt&8191,pt=Dt>>>13,Pt=a[6]|0,j=Pt&8191,dt=Pt>>>13,qt=a[7]|0,Q=qt&8191,ct=qt>>>13,Lt=a[8]|0,E=Lt&8191,w=Lt>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,zt=d[3]|0,nt=zt&8191,bt=zt>>>13,Kt=d[4]|0,ft=Kt&8191,yt=Kt>>>13,Ht=d[5]|0,at=Ht&8191,wt=Ht>>>13,Zt=d[6]|0,ht=Zt&8191,Mt=Zt>>>13,Wt=d[7]|0,st=Wt&8191,xt=Wt>>>13,Vt=d[8]|0,ot=Vt&8191,_t=Vt>>>13,Yt=d[9]|0,ut=Yt&8191,St=Yt>>>13;i.negative=t.negative^r.negative,i.length=19,u=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var Nt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),u=u+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var $t=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,u=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),u=u+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,u=u+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,u=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),u=u+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,u=u+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,u=u+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,u=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),u=u+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,u=u+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,u=u+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,u=u+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,u=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),u=u+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,u=u+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,u=u+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,u=u+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,u=u+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,u=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),u=u+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,u=u+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,u=u+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,u=u+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,u=u+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,u=u+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,u=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),u=u+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,u=u+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,u=u+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,u=u+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,u=u+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,u=u+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,u=u+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,u=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),u=u+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,u=u+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,u=u+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,u=u+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,u=u+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,u=u+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,u=u+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,u=u+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,u=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),u=u+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,u=u+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,u=u+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,u=u+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,u=u+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,u=u+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,u=u+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,u=u+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,u=u+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,u=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),u=u+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,u=u+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,u=u+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,u=u+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,u=u+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,u=u+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,u=u+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,u=u+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,u=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),u=u+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,u=u+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,u=u+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,u=u+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,u=u+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,u=u+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,u=u+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,u=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),u=u+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,u=u+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,u=u+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,u=u+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,u=u+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,u=u+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,u=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),u=u+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,u=u+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,u=u+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,u=u+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,u=u+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,u=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),u=u+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,u=u+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,u=u+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,u=u+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,u=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),u=u+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,u=u+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,u=u+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,u=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),u=u+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,u=u+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,u=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),u=u+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,u=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+u|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=Nt,c[1]=$t,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,u=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=u;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var u=v<<1,e=Math.cos(2*Math.PI/u),l=Math.sin(2*Math.PI/u),b=0;b<d;b+=u)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;o(d===0),o((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),u=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,u,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=u[q]*b[q]-e[q]*_[q];e[q]=u[q]*_[q]+e[q]*b[q],u[q]=O}return this.conjugate(u,e,a),this.transform(u,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){o(typeof t=="number"),o(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,u=(this.words[d]|0)-v<<r;this.words[d]=u|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return o(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){o(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,u=i;if(a-=c,a=Math.max(0,a),u){for(var e=0;e<c;e++)u.words[e]=this.words[e];u.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return u&&l!==0&&(u.words[u.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return o(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(o(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return o(typeof t=="number"),o(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(o(typeof t=="number"),o(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var u=(t.words[d]|0)*r;c-=u&67108863,v=(c>>26)-(u/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(o(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var u=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=u+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,u);b.negative===0&&(a=b,e&&(e.words[u]=1));for(var _=u-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(o(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){o(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){o(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){o(t.negative===0),o(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),u=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++u;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(u)}},f.prototype._invmp=function(t){o(t.negative===0),o(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,u=1;!(r.words[0]&u)&&v<26;++v,u<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){o(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),o(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return o(!this.red,"Already a number in reduction context"),o(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return o(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return o(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return o(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return o(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return o(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return o(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return o(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return o(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return o(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return o(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return o(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return o(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return o(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else o(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){o(t.negative===0,"red works only with positives"),o(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){o((t.negative|r.negative)===0,"red works only with positives"),o(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(o(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);o(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),u=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,u).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();o(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,u=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){u=0;continue}v<<=1,v|=_,u++,!(u!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),u=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Gt)})(Y0);var Fm=Y0.exports,Gf,lh;function qm(){if(lh)return Gf;lh=1;var h=Z0(),n=Fm;Gf=function(g){return new o(g)};var s={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};s.p224=s.secp224r1,s.p256=s.secp256r1=s.prime256v1,s.p192=s.secp192r1=s.prime192v1,s.p384=s.secp384r1,s.p521=s.secp521r1;function o(f){this.curveType=s[f],this.curveType||(this.curveType={name:f}),this.curve=new h.ec(this.curveType.name),this.keys=void 0}o.prototype.generateKeys=function(f,g){return this.keys=this.curve.genKeyPair(),this.getPublicKey(f,g)},o.prototype.computeSecret=function(f,g,y){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var S=this.curve.keyFromPublic(f).getPublic(),B=S.mul(this.keys.getPrivate()).getX();return m(B,y,this.curveType.byteLength)},o.prototype.getPublicKey=function(f,g){var y=this.keys.getPublic(g==="compressed",!0);return g==="hybrid"&&(y[y.length-1]%2?y[0]=7:y[0]=6),m(y,f)},o.prototype.getPrivateKey=function(f){return m(this.keys.getPrivate(),f)},o.prototype.setPublicKey=function(f,g){return g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g)),this.keys._importPublic(f),this},o.prototype.setPrivateKey=function(f,g){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var y=new n(f);return y=y.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(y),this};function m(f,g,y){Array.isArray(f)||(f=f.toArray());var S=new mt(f);if(y&&S.length<y){var B=new mt(y-S.length);B.fill(0),S=mt.concat([B,S])}return g?S.toString(g):S}return Gf}var Lo={},Pm=Gi,v0=Ot.Buffer,Oo=function(h,n){for(var s=v0.alloc(0),o=0,m;s.length<n;)m=Dm(o++),s=v0.concat([s,Pm("sha1").update(h).update(m).digest()]);return s.slice(0,n)};function Dm(h){var n=v0.allocUnsafe(4);return n.writeUInt32BE(h,0),n}var zo=function(n,s){for(var o=n.length,m=-1;++m<o;)n[m]^=s[m];return n},J0={exports:{}};J0.exports;(function(h){(function(n,s){function o(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:s.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=De.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),o(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(o(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(o(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var u=t.length-r;for(a=u%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,u=Math.min(c,c-v)+i,e=0,l=i;l<u;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){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"],x=[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],I=[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];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],u=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-u.length]+u+i:i=u+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}o(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&o(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return o(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);o(a<=d,"byte array longer than desired length"),o(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),u,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[e]=u;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[d-e-1]=u}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return o((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return o((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return o((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){o(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){o(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,u=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=u>>>26,b=u&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,u=l|0}return u!==0?r.words[e]=u|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,u,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,Ft=a[4]|0,tt=Ft&8191,vt=Ft>>>13,Dt=a[5]|0,et=Dt&8191,pt=Dt>>>13,Pt=a[6]|0,j=Pt&8191,dt=Pt>>>13,qt=a[7]|0,Q=qt&8191,ct=qt>>>13,Lt=a[8]|0,E=Lt&8191,w=Lt>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,zt=d[3]|0,nt=zt&8191,bt=zt>>>13,Kt=d[4]|0,ft=Kt&8191,yt=Kt>>>13,Ht=d[5]|0,at=Ht&8191,wt=Ht>>>13,Zt=d[6]|0,ht=Zt&8191,Mt=Zt>>>13,Wt=d[7]|0,st=Wt&8191,xt=Wt>>>13,Vt=d[8]|0,ot=Vt&8191,_t=Vt>>>13,Yt=d[9]|0,ut=Yt&8191,St=Yt>>>13;i.negative=t.negative^r.negative,i.length=19,u=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var Nt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),u=u+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var $t=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,u=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),u=u+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,u=u+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,u=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),u=u+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,u=u+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,u=u+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,u=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),u=u+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,u=u+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,u=u+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,u=u+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,u=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),u=u+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,u=u+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,u=u+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,u=u+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,u=u+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,u=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),u=u+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,u=u+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,u=u+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,u=u+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,u=u+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,u=u+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,u=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),u=u+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,u=u+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,u=u+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,u=u+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,u=u+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,u=u+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,u=u+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,u=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),u=u+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,u=u+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,u=u+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,u=u+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,u=u+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,u=u+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,u=u+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,u=u+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,u=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),u=u+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,u=u+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,u=u+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,u=u+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,u=u+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,u=u+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,u=u+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,u=u+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,u=u+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,u=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),u=u+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,u=u+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,u=u+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,u=u+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,u=u+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,u=u+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,u=u+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,u=u+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,u=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),u=u+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,u=u+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,u=u+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,u=u+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,u=u+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,u=u+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,u=u+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,u=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),u=u+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,u=u+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,u=u+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,u=u+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,u=u+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,u=u+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,u=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),u=u+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,u=u+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,u=u+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,u=u+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,u=u+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,u=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),u=u+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,u=u+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,u=u+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,u=u+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,u=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),u=u+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,u=u+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,u=u+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,u=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),u=u+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,u=u+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,u=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),u=u+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,u=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+u|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=Nt,c[1]=$t,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,u=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=u;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var u=v<<1,e=Math.cos(2*Math.PI/u),l=Math.sin(2*Math.PI/u),b=0;b<d;b+=u)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;o(d===0),o((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),u=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,u,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=u[q]*b[q]-e[q]*_[q];e[q]=u[q]*_[q]+e[q]*b[q],u[q]=O}return this.conjugate(u,e,a),this.transform(u,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){o(typeof t=="number"),o(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,u=(this.words[d]|0)-v<<r;this.words[d]=u|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return o(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){o(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,u=i;if(a-=c,a=Math.max(0,a),u){for(var e=0;e<c;e++)u.words[e]=this.words[e];u.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return u&&l!==0&&(u.words[u.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return o(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){o(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(o(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return o(typeof t=="number"),o(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(o(typeof t=="number"),o(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var u=(t.words[d]|0)*r;c-=u&67108863,v=(c>>26)-(u/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(o(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var u=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=u+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,u);b.negative===0&&(a=b,e&&(e.words[u]=1));for(var _=u-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(o(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){o(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){o(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){o(t.negative===0),o(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),u=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++u;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(u)}},f.prototype._invmp=function(t){o(t.negative===0),o(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,u=1;!(r.words[0]&u)&&v<26;++v,u<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){o(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),o(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return o(!this.red,"Already a number in reduction context"),o(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return o(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return o(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return o(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return o(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return o(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return o(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return o(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return o(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return o(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return o(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return o(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return o(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return o(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return o(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else o(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){o(t.negative===0,"red works only with positives"),o(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){o((t.negative|r.negative)===0,"red works only with positives"),o(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(o(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);o(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),u=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,u).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();o(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,u=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){u=0;continue}v<<=1,v|=_,u++,!(u!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),u=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Gt)})(J0);var G0=J0.exports,dh=G0,Nm=Ot.Buffer;function $m(h,n){return Nm.from(h.toRed(dh.mont(n.modulus)).redPow(new dh(n.publicExponent)).fromRed().toArray())}var Ko=$m,Um=sf,p0=gi,Lm=Gi,ch=Oo,vh=zo,X0=G0,Om=Ko,zm=U0,je=Ot.Buffer,Km=function(n,s,o){var m;n.padding?m=n.padding:o?m=1:m=4;var f=Um(n),g;if(m===4)g=Hm(f,s);else if(m===1)g=Zm(f,s,o);else if(m===3){if(g=new X0(s),g.cmp(f.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return o?zm(g,f):Om(g,f)};function Hm(h,n){var s=h.modulus.byteLength(),o=n.length,m=Lm("sha1").update(je.alloc(0)).digest(),f=m.length,g=2*f;if(o>s-g-2)throw new Error("message too long");var y=je.alloc(s-o-g-2),S=s-f-1,B=p0(f),M=vh(je.concat([m,y,je.alloc(1,1),n],S),ch(B,S)),x=vh(B,ch(M,f));return new X0(je.concat([je.alloc(1),x,M],s))}function Zm(h,n,s){var o=n.length,m=h.modulus.byteLength();if(o>m-11)throw new Error("message too long");var f;return s?f=je.alloc(m-o-3,255):f=Wm(m-o-3),new X0(je.concat([je.from([0,s?1:2]),f,je.alloc(1),n],m))}function Wm(h){for(var n=je.allocUnsafe(h),s=0,o=p0(h*2),m=0,f;s<h;)m===o.length&&(o=p0(h*2),m=0),f=o[m++],f&&(n[s++]=f);return n}var Vm=sf,ph=Oo,mh=zo,gh=G0,Ym=U0,Jm=Gi,Gm=Ko,Hi=Ot.Buffer,Xm=function(n,s,o){var m;n.padding?m=n.padding:o?m=1:m=4;var f=Vm(n),g=f.modulus.byteLength();if(s.length>g||new gh(s).cmp(f.modulus)>=0)throw new Error("decryption error");var y;o?y=Gm(new gh(s),f):y=Ym(s,f);var S=Hi.alloc(g-y.length);if(y=Hi.concat([S,y],g),m===4)return jm(f,y);if(m===1)return Qm(f,y,o);if(m===3)return y;throw new Error("unknown padding")};function jm(h,n){var s=h.modulus.byteLength(),o=Jm("sha1").update(Hi.alloc(0)).digest(),m=o.length;if(n[0]!==0)throw new Error("decryption error");var f=n.slice(1,m+1),g=n.slice(m+1),y=mh(f,ph(g,m)),S=mh(g,ph(y,s-m-1));if(tg(o,S.slice(0,m)))throw new Error("decryption error");for(var B=m;S[B]===0;)B++;if(S[B++]!==1)throw new Error("decryption error");return S.slice(B)}function Qm(h,n,s){for(var o=n.slice(0,2),m=2,f=0;n[m++]!==0;)if(m>=n.length){f++;break}var g=n.slice(2,m-1);if((o.toString("hex")!=="0002"&&!s||o.toString("hex")!=="0001"&&s)&&f++,g.length<8&&f++,f)throw new Error("decryption error");return n.slice(m)}function tg(h,n){h=Hi.from(h),n=Hi.from(n);var s=0,o=h.length;h.length!==n.length&&(s++,o=Math.min(h.length,n.length));for(var m=-1;++m<o;)s+=h[m]^n[m];return s}(function(h){h.publicEncrypt=Km,h.privateDecrypt=Xm,h.privateEncrypt=function(s,o){return h.publicEncrypt(s,o,!0)},h.publicDecrypt=function(s,o){return h.privateDecrypt(s,o,!0)}})(Lo);var Ni={};function bh(){throw new Error(`secure random number generation not supported by this browser
|
|
16
16
|
use chrome, FireFox or Internet Explorer 11`)}var Ho=Ot,yh=gi,Zo=Ho.Buffer,Wo=Ho.kMaxLength,m0=Gt.crypto||Gt.msCrypto,Vo=Math.pow(2,32)-1;function Yo(h,n){if(typeof h!="number"||h!==h)throw new TypeError("offset must be a number");if(h>Vo||h<0)throw new TypeError("offset must be a uint32");if(h>Wo||h>n)throw new RangeError("offset out of range")}function Jo(h,n,s){if(typeof h!="number"||h!==h)throw new TypeError("size must be a number");if(h>Vo||h<0)throw new TypeError("size must be a uint32");if(h+n>s||h>Wo)throw new RangeError("buffer too small")}m0&&m0.getRandomValues||!ye.browser?(Ni.randomFill=eg,Ni.randomFillSync=rg):(Ni.randomFill=bh,Ni.randomFillSync=bh);function eg(h,n,s,o){if(!Zo.isBuffer(h)&&!(h instanceof Gt.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof n=="function")o=n,n=0,s=h.length;else if(typeof s=="function")o=s,s=h.length-n;else if(typeof o!="function")throw new TypeError('"cb" argument must be a function');return Yo(n,h.length),Jo(s,n,h.length),Go(h,n,s,o)}function Go(h,n,s,o){if(ye.browser){var m=h.buffer,f=new Uint8Array(m,n,s);if(m0.getRandomValues(f),o){ye.nextTick(function(){o(null,h)});return}return h}if(o){yh(s,function(y,S){if(y)return o(y);S.copy(h,n),o(null,h)});return}var g=yh(s);return g.copy(h,n),h}function rg(h,n,s){if(typeof n=="undefined"&&(n=0),!Zo.isBuffer(h)&&!(h instanceof Gt.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Yo(n,h.length),s===void 0&&(s=h.length-n),Jo(s,n,h.length),Go(h,n,s)}var wh;function Xo(){if(wh)return Ut;wh=1,Ut.randomBytes=Ut.rng=Ut.pseudoRandomBytes=Ut.prng=gi,Ut.createHash=Ut.Hash=Gi,Ut.createHmac=Ut.Hmac=Vh;var h=Wd,n=Object.keys(h),s=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);Ut.getHashes=function(){return s};var o=Un;Ut.pbkdf2=o.pbkdf2,Ut.pbkdf2Sync=o.pbkdf2Sync;var m=Qe;Ut.Cipher=m.Cipher,Ut.createCipher=m.createCipher,Ut.Cipheriv=m.Cipheriv,Ut.createCipheriv=m.createCipheriv,Ut.Decipher=m.Decipher,Ut.createDecipher=m.createDecipher,Ut.Decipheriv=m.Decipheriv,Ut.createDecipheriv=m.createDecipheriv,Ut.getCiphers=m.getCiphers,Ut.listCiphers=m.listCiphers;var f=rv();Ut.DiffieHellmanGroup=f.DiffieHellmanGroup,Ut.createDiffieHellmanGroup=f.createDiffieHellmanGroup,Ut.getDiffieHellman=f.getDiffieHellman,Ut.createDiffieHellman=f.createDiffieHellman,Ut.DiffieHellman=f.DiffieHellman;var g=Cm();Ut.createSign=g.createSign,Ut.Sign=g.Sign,Ut.createVerify=g.createVerify,Ut.Verify=g.Verify,Ut.createECDH=qm();var y=Lo;Ut.publicEncrypt=y.publicEncrypt,Ut.privateEncrypt=y.privateEncrypt,Ut.publicDecrypt=y.publicDecrypt,Ut.privateDecrypt=y.privateDecrypt;var S=Ni;return Ut.randomFill=S.randomFill,Ut.randomFillSync=S.randomFillSync,Ut.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
|
|
17
17
|
we accept pull requests
|
|
18
|
-
https://github.com/browserify/crypto-browserify`)},Ut.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},Ut}var ig=Xo();const ng=cu(ig);function j0(h){const n=ng.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function jo(h,n){const s=j0(h);let o=0;for(const m of n.variants)if(o+=m.weight,s<o)return m.value;return null}function Qo(h,n){const s=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!s)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:o,salt:m}=h;return j0(`${s}.${m}`)<o?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:o,variants:m}=h;return jo(`${s}.${o}`,m)}default:return null}}function tu(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?_u(S,n):!1}else return Sh(g,n)}))return null;const m=h.rollout?Qo(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let an={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function fg(h){an=h}function eu(h){return`flagmint_${h}_flags`}function ru(h){return`flagmint_${h}_context`}function iu(h,n){try{const s=an.getItem(eu(h));if(!s)return null;const o=JSON.parse(s);return Date.now()-o.ts>n?null:o.data}catch(s){return null}}function nu(h,n){try{an.setItem(eu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(s){}}function fu(h){try{const n=an.getItem(ru(h));return n?JSON.parse(n):null}catch(n){return null}}function au(h,n){try{an.setItem(ru(h),JSON.stringify(n))}catch(s){}}const ag=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:fu,loadCachedFlags:iu,saveCachedContext:au,saveCachedFlags:nu,setCacheStorage:fg},Symbol.toStringTag,{value:"Module"})),hg=24*60*60*1e3;function hu(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const sg=hu().rest,og=hu().ws;class ug{constructor(n){var s,o,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(s=n.enableOfflineCache)!=null?s:!0,this.persistContext=(o=n.persistContext)!=null?o:!1,this.cacheTTL=hg,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:sg,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:og,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:iu,saveFlags:nu,loadContext:fu,saveContext:au},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return ke(this,null,function*(){var s;
|
|
18
|
+
https://github.com/browserify/crypto-browserify`)},Ut.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},Ut}var ig=Xo();const ng=cu(ig);function j0(h){const n=ng.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function jo(h,n){const s=j0(h);let o=0;for(const m of n.variants)if(o+=m.weight,s<o)return m.value;return null}function Qo(h,n){const s=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!s)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:o,salt:m}=h;return j0(`${s}.${m}`)<o?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:o,variants:m}=h;return jo(`${s}.${o}`,m)}default:return null}}function tu(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?_u(S,n):!1}else return Sh(g,n)}))return null;const m=h.rollout?Qo(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let an={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function fg(h){an=h}function eu(h){return`flagmint_${h}_flags`}function ru(h){return`flagmint_${h}_context`}function iu(h,n){try{const s=an.getItem(eu(h));if(!s)return null;const o=JSON.parse(s);return Date.now()-o.ts>n?null:o.data}catch(s){return null}}function nu(h,n){try{an.setItem(eu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(s){}}function fu(h){try{const n=an.getItem(ru(h));return n?JSON.parse(n):null}catch(n){return null}}function au(h,n){try{an.setItem(ru(h),JSON.stringify(n))}catch(s){}}const ag=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:fu,loadCachedFlags:iu,saveCachedContext:au,saveCachedFlags:nu,setCacheStorage:fg},Symbol.toStringTag,{value:"Module"})),hg=24*60*60*1e3;function hu(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const sg=hu().rest,og=hu().ws;class ug{constructor(n){var s,o,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(s=n.enableOfflineCache)!=null?s:!0,this.persistContext=(o=n.persistContext)!=null?o:!1,this.cacheTTL=hg,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:sg,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:og,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:iu,saveFlags:nu,loadContext:fu,saveContext:au},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return ke(this,null,function*(){var s;if(console.log("[FlagClient] Initialization started with options:",n),this.isInitialized){console.log("[FlagClient] Already initialized, skipping.");return}try{if(this.persistContext){const o=yield Promise.resolve(this.cacheAdapter.loadContext(this.apiKey));o&&(this.context=o)}if(this.enableOfflineCache){const o=yield Promise.resolve(this.cacheAdapter.loadFlags(this.apiKey,this.cacheTTL));o&&(this.flags=o,this.notifySubscribers())}yield this.setupTransport(n),this.isInitialized=!0,this.resolveReady()}catch(o){this.rejectReady(o),(s=this.onError)==null||s.call(this,o)}})}setupTransport(n){return ke(this,null,function*(){var f;console.log("[FlagClient] setupTransport() started");const s=(f=n.transportMode)!=null?f:"auto",o=()=>ke(this,null,function*(){console.log("[FlagClient] Initializing WebSocket transport...");const g=new _h(this.wsEndpoint,this.apiKey);return yield g.init(),console.log("[FlagClient] WebSocket transport initialized"),g}),m=()=>{const g=new xh(this.restEndpoint,this.apiKey,this.context,{pollIntervalMs:12e5,maxBackoffMs:6e4,backoffMultiplier:2});return g.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via long polling:",y),this.updateFlags(y)}),g.init(),g};try{if(s==="websocket")this.transport=yield o();else if(s==="long-polling")this.transport=m();else try{this.transport=yield o()}catch(y){console.warn("[FlagClient] WebSocket failed, falling back to long polling"),this.transport=m()}console.log("[FlagClient] Fetching flags...");const g=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Initial flags fetched:",g),this.updateFlags(g),typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via transport:",y),this.updateFlags(y)}),this.resolveReady()}catch(g){throw console.error("[FlagClient] setupTransport error:",g),this.rejectReady(g),this.onError&&this.onError(g instanceof Error?g:new Error(String(g))),g}})}updateFlags(n){this.flags=n,this.enableOfflineCache&&Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,n)),this.notifySubscribers()}notifySubscribers(){this.subscribers.forEach(n=>{try{n(this.flags)}catch(s){console.error("[FlagClient] Error in subscriber callback:",s)}})}subscribe(n){return this.subscribers.add(n),n(this.flags),()=>{this.subscribers.delete(n)}}getFlags(){return hn({},this.flags)}getFlag(n,s){var o;return(o=this.flags[n])!=null?o:s}updateContext(n){return ke(this,null,function*(){var s;if(this.context=hn(hn({},this.context),n),console.log("[FlagClient] Context updated:",this.context),this.persistContext&&(yield Promise.resolve(this.cacheAdapter.saveContext(this.apiKey,this.context))),this.transport&&typeof this.transport.fetchFlags=="function")try{const o=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Context persisted:",this.context,o),this.updateFlags(o)}catch(o){console.error("[FlagClient] Error updating flags after context change:",o),(s=this.onError)==null||s.call(this,o)}})}destroy(){this.refreshIntervalId&&clearInterval(this.refreshIntervalId),this.subscribers.clear(),this.transport&&this.transport.destroy()}ready(){return ke(this,null,function*(){return console.log("[FlagClient] Waiting for client to be ready..."),this.deferInitialization&&!this.isInitialized&&this.initializationOptions&&(console.log("[FlagClient] Deferred initialization triggered by ready() call"),yield this.initialize(this.initializationOptions)),this.readyPromise})}evaluateLocally(n,s){const o={};for(const m in n){const f=tu(n[m],s);f!==null&&(o[m]=f)}return o}}function su(h){return`flagmint_${h}_flags`}function ou(h){return`flagmint_${h}_context`}let Ir=null;function lg(h){Ir=h}function dg(h,n){return ke(this,null,function*(){if(!Ir)throw new Error("Async storage not set");try{const s=yield Ir.getItem(su(h));if(!s)return null;const o=JSON.parse(s);return Date.now()-o.ts>n?null:o.data}catch(s){return null}})}function cg(h,n){return ke(this,null,function*(){if(!Ir)throw new Error("Async storage not set");try{yield Ir.setItem(su(h),JSON.stringify({ts:Date.now(),data:n}))}catch(s){}})}function vg(h){return ke(this,null,function*(){if(!Ir)throw new Error("Async storage not set");try{const n=yield Ir.getItem(ou(h));return n?JSON.parse(n):null}catch(n){return null}})}function pg(h,n){return ke(this,null,function*(){if(!Ir)throw new Error("Async storage not set");try{yield Ir.setItem(ou(h),JSON.stringify(n))}catch(s){}})}const mg=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:vg,loadCachedFlags:dg,saveCachedContext:pg,saveCachedFlags:cg,setAsyncCacheStorage:lg},Symbol.toStringTag,{value:"Module"}));typeof globalThis.Buffer=="undefined"&&(globalThis.Buffer=gr.Buffer);exports.FlagClient=ug;exports.LongPollingTransport=xh;exports.WebSocketTransport=_h;exports.asyncCache=mg;exports.evaluateFlagValue=tu;exports.evaluateRollout=Qo;exports.hashToPercentage=j0;exports.pickVariant=jo;exports.syncCache=ag;
|
package/dist/flagmint.es.js
CHANGED
|
@@ -20260,7 +20260,10 @@ class gg {
|
|
|
20260
20260
|
initialize(n) {
|
|
20261
20261
|
return ke(this, null, function* () {
|
|
20262
20262
|
var s;
|
|
20263
|
-
|
|
20263
|
+
if (console.log("[FlagClient] Initialization started with options:", n), this.isInitialized) {
|
|
20264
|
+
console.log("[FlagClient] Already initialized, skipping.");
|
|
20265
|
+
return;
|
|
20266
|
+
}
|
|
20264
20267
|
try {
|
|
20265
20268
|
if (this.persistContext) {
|
|
20266
20269
|
const o = yield Promise.resolve(
|
package/dist/flagmint.umd.js
CHANGED
|
@@ -15,4 +15,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}var Xu=zt.Buffer,cn=Ft.crypto||Ft.
|
|
|
15
15
|
`)},O0}var xo;function v2(){return xo||(xo=1,function(h){var n=h;n.der=wo(),n.pem=c2()}(U0)),U0}var _o;function sn(){return _o||(_o=1,function(h){var n=h;n.bignum=a2,n.define=h2().define,n.base=hn(),n.constants=vo(),n.decoders=d2(),n.encoders=v2()}(I0)),I0}var ar=sn(),So=ar.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),p2=ar.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),z0=ar.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),m2=ar.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(z0),this.key("subjectPublicKey").bitstr())}),g2=ar.define("RelativeDistinguishedName",function(){this.setof(p2)}),b2=ar.define("RDNSequence",function(){this.seqof(g2)}),Ao=ar.define("Name",function(){this.choice({rdnSequence:this.use(b2)})}),y2=ar.define("Validity",function(){this.seq().obj(this.key("notBefore").use(So),this.key("notAfter").use(So))}),w2=ar.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),M2=ar.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(z0),this.key("issuer").use(Ao),this.key("validity").use(y2),this.key("subject").use(Ao),this.key("subjectPublicKeyInfo").use(m2),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(w2).optional())}),x2=ar.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(M2),this.key("signatureAlgorithm").use(z0),this.key("signatureValue").bitstr())}),_2=x2,hr=sn();fr.certificate=_2;var S2=hr.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())});fr.RSAPrivateKey=S2;var A2=hr.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});fr.RSAPublicKey=A2;var Bo=hr.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())}),B2=hr.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(Bo),this.key("subjectPublicKey").bitstr())});fr.PublicKey=B2;var E2=hr.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(Bo),this.key("subjectPrivateKey").octstr())});fr.PrivateKey=E2;var k2=hr.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())});fr.EncryptedPrivateKey=k2;var I2=hr.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())});fr.DSAPrivateKey=I2,fr.DSAparam=hr.define("DSAparam",function(){this.int()});var R2=hr.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),T2=hr.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(R2),this.key("publicKey").optional().explicit(1).bitstr())});fr.ECPrivateKey=T2,fr.signature=hr.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())});const C2={"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 F2=/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,q2=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,P2=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,D2=Ln,N2=Ze,uf=zt.Buffer,$2=function(h,n){var u=h.toString(),s=u.match(F2),m;if(s){var g="aes"+s[1],y=uf.from(s[2],"hex"),S=uf.from(s[3].replace(/[\r\n]/g,""),"base64"),B=D2(n,y.slice(0,8),parseInt(s[1],10)).key,M=[],x=N2.createDecipheriv(g,B,y);M.push(x.update(S)),M.push(x.final()),m=uf.concat(M)}else{var f=u.match(P2);m=uf.from(f[2].replace(/[\r\n]/g,""),"base64")}var I=u.match(q2)[1];return{tag:I,data:m}},ze=fr,U2=C2,L2=$2,O2=Ze,z2=_n,K0=zt.Buffer;function K2(h,n){var u=h.algorithm.decrypt.kde.kdeparams.salt,s=parseInt(h.algorithm.decrypt.kde.kdeparams.iters.toString(),10),m=U2[h.algorithm.decrypt.cipher.algo.join(".")],f=h.algorithm.decrypt.cipher.iv,g=h.subjectPrivateKey,y=parseInt(m.split("-")[1],10)/8,S=z2.pbkdf2Sync(n,u,s,y,"sha1"),B=O2.createDecipheriv(m,S,f),M=[];return M.push(B.update(g)),M.push(B.final()),K0.concat(M)}function Eo(h){var n;typeof h=="object"&&!K0.isBuffer(h)&&(n=h.passphrase,h=h.key),typeof h=="string"&&(h=K0.from(h));var u=L2(h,n),s=u.tag,m=u.data,f,g;switch(s){case"CERTIFICATE":g=ze.certificate.decode(m,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(g||(g=ze.PublicKey.decode(m,"der")),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return ze.RSAPublicKey.decode(g.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return g.subjectPrivateKey=g.subjectPublicKey,{type:"ec",data:g};case"1.2.840.10040.4.1":return g.algorithm.params.pub_key=ze.DSAparam.decode(g.subjectPublicKey.data,"der"),{type:"dsa",data:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"ENCRYPTED PRIVATE KEY":m=ze.EncryptedPrivateKey.decode(m,"der"),m=K2(m,n);case"PRIVATE KEY":switch(g=ze.PrivateKey.decode(m,"der"),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return ze.RSAPrivateKey.decode(g.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:g.algorithm.curve,privateKey:ze.ECPrivateKey.decode(g.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return g.algorithm.params.priv_key=ze.DSAparam.decode(g.subjectPrivateKey,"der"),{type:"dsa",params:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"RSA PUBLIC KEY":return ze.RSAPublicKey.decode(m,"der");case"RSA PRIVATE KEY":return ze.RSAPrivateKey.decode(m,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:ze.DSAPrivateKey.decode(m,"der")};case"EC PRIVATE KEY":return m=ze.ECPrivateKey.decode(m,"der"),{curve:m.parameters.value,privateKey:m.privateKey};default:throw new Error("unknown key type "+s)}}Eo.signature=ze.signature;var lf=Eo;const ko={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var Io;function H2(){if(Io)return en.exports;Io=1;var h=zt.Buffer,n=La,u=l0,s=k0().ec,m=u0,f=lf,g=ko,y=1;function S(z,$,lt,H,At){var Bt=f($);if(Bt.curve){if(H!=="ecdsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");return B(z,Bt)}else if(Bt.type==="dsa"){if(H!=="dsa")throw new Error("wrong private key type");return M(z,Bt,lt)}if(H!=="rsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");if($.padding!==void 0&&$.padding!==y)throw new Error("illegal or unsupported padding mode");z=h.concat([At,z]);for(var Ct=Bt.modulus.byteLength(),Et=[0,1];z.length+Et.length+1<Ct;)Et.push(255);Et.push(0);for(var Y=-1;++Y<z.length;)Et.push(z[Y]);var It=u(Et,Bt);return It}function B(z,$){var lt=g[$.curve.join(".")];if(!lt)throw new Error("unknown curve "+$.curve.join("."));var H=new s(lt),At=H.keyFromPrivate($.privateKey),Bt=At.sign(z);return h.from(Bt.toDER())}function M(z,$,lt){for(var H=$.params.priv_key,At=$.params.p,Bt=$.params.q,Ct=$.params.g,Et=new m(0),Y,It=k(z,Bt).mod(Bt),p=!1,t=I(H,Bt,z,lt);p===!1;)Y=L(Bt,t,lt),Et=W(Ct,Y,At,Bt),p=Y.invm(Bt).imul(It.add(H.mul(Et))).mod(Bt),p.cmpn(0)===0&&(p=!1,Et=new m(0));return x(Et,p)}function x(z,$){z=z.toArray(),$=$.toArray(),z[0]&128&&(z=[0].concat(z)),$[0]&128&&($=[0].concat($));var lt=z.length+$.length+4,H=[48,lt,2,z.length];return H=H.concat(z,[2,$.length],$),h.from(H)}function I(z,$,lt,H){if(z=h.from(z.toArray()),z.length<$.byteLength()){var At=h.alloc($.byteLength()-z.length);z=h.concat([At,z])}var Bt=lt.length,Ct=D(lt,$),Et=h.alloc(Bt);Et.fill(1);var Y=h.alloc(Bt);return Y=n(H,Y).update(Et).update(h.from([0])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),Y=n(H,Y).update(Et).update(h.from([1])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),{k:Y,v:Et}}function k(z,$){var lt=new m(z),H=(z.length<<3)-$.bitLength();return H>0&<.ishrn(H),lt}function D(z,$){z=k(z,$),z=z.mod($);var lt=h.from(z.toArray());if(lt.length<$.byteLength()){var H=h.alloc($.byteLength()-lt.length);lt=h.concat([H,lt])}return lt}function L(z,$,lt){var H,At;do{for(H=h.alloc(0);H.length*8<z.bitLength();)$.v=n(lt,$.k).update($.v).digest(),H=h.concat([H,$.v]);At=k(H,z),$.k=n(lt,$.k).update($.v).update(h.from([0])).digest(),$.v=n(lt,$.k).update($.v).digest()}while(At.cmp(z)!==-1);return At}function W(z,$,lt,H){return z.toRed(m.mont(lt)).redPow($).fromRed().mod(H)}return en.exports=S,en.exports.getKey=I,en.exports.makeKey=L,en.exports}var H0,Ro;function Z2(){if(Ro)return H0;Ro=1;var h=zt.Buffer,n=u0,u=k0().ec,s=lf,m=ko;function f(B,M,x,I,k){var D=s(x);if(D.type==="ec"){if(I!=="ecdsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");return g(B,M,D)}else if(D.type==="dsa"){if(I!=="dsa")throw new Error("wrong public key type");return y(B,M,D)}if(I!=="rsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");M=h.concat([k,M]);for(var L=D.modulus.byteLength(),W=[1],z=0;M.length+W.length+2<L;)W.push(255),z+=1;W.push(0);for(var $=-1;++$<M.length;)W.push(M[$]);W=h.from(W);var lt=n.mont(D.modulus);B=new n(B).toRed(lt),B=B.redPow(new n(D.publicExponent)),B=h.from(B.fromRed().toArray());var H=z<8?1:0;for(L=Math.min(B.length,W.length),B.length!==W.length&&(H=1),$=-1;++$<L;)H|=B[$]^W[$];return H===0}function g(B,M,x){var I=m[x.data.algorithm.curve.join(".")];if(!I)throw new Error("unknown curve "+x.data.algorithm.curve.join("."));var k=new u(I),D=x.data.subjectPrivateKey.data;return k.verify(M,B,D)}function y(B,M,x){var I=x.data.p,k=x.data.q,D=x.data.g,L=x.data.pub_key,W=s.signature.decode(B,"der"),z=W.s,$=W.r;S(z,k),S($,k);var lt=n.mont(I),H=z.invm(k),At=D.toRed(lt).redPow(new n(M).mul(H).mod(k)).fromRed().mul(L.toRed(lt).redPow($.mul(H).mod(k)).fromRed()).mod(I).mod(k);return At.cmp($)===0}function S(B,M){if(B.cmpn(0)<=0)throw new Error("invalid sig");if(B.cmp(M)>=0)throw new Error("invalid sig")}return H0=f,H0}var Z0,To;function W2(){if(To)return Z0;To=1;var h=zt.Buffer,n=Ki,u=rv,s=Kt,m=H2(),f=Z2(),g=Oa;Object.keys(g).forEach(function(x){g[x].id=h.from(g[x].id,"hex"),g[x.toLowerCase()]=g[x]});function y(x){u.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hashType=I.hash,this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}s(y,u.Writable),y.prototype._write=function(I,k,D){this._hash.update(I),D()},y.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},y.prototype.sign=function(I,k){this.end();var D=this._hash.digest(),L=m(D,I,this._hashType,this._signType,this._tag);return k?L.toString(k):L};function S(x){u.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}s(S,u.Writable),S.prototype._write=function(I,k,D){this._hash.update(I),D()},S.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},S.prototype.verify=function(I,k,D){var L=typeof k=="string"?h.from(k,D):k;this.end();var W=this._hash.digest();return f(L,W,I,this._signType,this._tag)};function B(x){return new y(x)}function M(x){return new S(x)}return Z0={Sign:B,Verify:M,createSign:B,createVerify:M},Z0}var W0={exports:{}};W0.exports,function(h){(function(n,u){function s(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:u.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=Ne.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),s(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(s(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(s(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var o=t.length-r;for(a=o%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,o=Math.min(c,c-v)+i,e=0,l=i;l<o;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){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"],x=[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],I=[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];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],o=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-o.length]+o+i:i=o+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}s(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return s(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);s(a<=d,"byte array longer than desired length"),s(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),o,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)o=l.andln(255),l.iushrn(8),v[e]=o;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)o=l.andln(255),l.iushrn(8),v[d-e-1]=o}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return s((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return s((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return s((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){s(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){s(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,o=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=o>>>26,b=o&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,o=l|0}return o!==0?r.words[e]=o|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,o,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Nt=a[5]|0,et=Nt&8191,pt=Nt>>>13,Dt=a[6]|0,j=Dt&8191,dt=Dt>>>13,Pt=a[7]|0,Q=Pt&8191,ct=Pt>>>13,Ot=a[8]|0,E=Ot&8191,w=Ot>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,Ht=d[3]|0,nt=Ht&8191,bt=Ht>>>13,Zt=d[4]|0,ft=Zt&8191,yt=Zt>>>13,Wt=d[5]|0,at=Wt&8191,wt=Wt>>>13,Vt=d[6]|0,ht=Vt&8191,Mt=Vt>>>13,Yt=d[7]|0,st=Yt&8191,xt=Yt>>>13,Jt=d[8]|0,ot=Jt&8191,_t=Jt>>>13,Gt=d[9]|0,ut=Gt&8191,St=Gt>>>13;i.negative=t.negative^r.negative,i.length=19,o=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var $t=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,o=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),o=o+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var Ut=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,o=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),o=o+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,o=o+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,o=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),o=o+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,o=o+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,o=o+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,o=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),o=o+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,o=o+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,o=o+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,o=o+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,o=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),o=o+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,o=o+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,o=o+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,o=o+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,o=o+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,o=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),o=o+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,o=o+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,o=o+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,o=o+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,o=o+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,o=o+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,o=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),o=o+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,o=o+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,o=o+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,o=o+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,o=o+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,o=o+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,o=o+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,o=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),o=o+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,o=o+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,o=o+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,o=o+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,o=o+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,o=o+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,o=o+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,o=o+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,o=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),o=o+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,o=o+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,o=o+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,o=o+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,o=o+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,o=o+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,o=o+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,o=o+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,o=o+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,o=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),o=o+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,o=o+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,o=o+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,o=o+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,o=o+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,o=o+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,o=o+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,o=o+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,o=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),o=o+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,o=o+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,o=o+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,o=o+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,o=o+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,o=o+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,o=o+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,o=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),o=o+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,o=o+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,o=o+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,o=o+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,o=o+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,o=o+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,o=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),o=o+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,o=o+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,o=o+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,o=o+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,o=o+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,o=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),o=o+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,o=o+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,o=o+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,o=o+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,o=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),o=o+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,o=o+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,o=o+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,o=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),o=o+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,o=o+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,o=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),o=o+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,o=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+o|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=$t,c[1]=Ut,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,o=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=o;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var o=v<<1,e=Math.cos(2*Math.PI/o),l=Math.sin(2*Math.PI/o),b=0;b<d;b+=o)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==o&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;s(d===0),s((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),o=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,o,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=o[q]*b[q]-e[q]*_[q];e[q]=o[q]*_[q]+e[q]*b[q],o[q]=O}return this.conjugate(o,e,a),this.transform(o,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){s(typeof t=="number"),s(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,o=(this.words[d]|0)-v<<r;this.words[d]=o|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return s(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){s(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,o=i;if(a-=c,a=Math.max(0,a),o){for(var e=0;e<c;e++)o.words[e]=this.words[e];o.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return o&&l!==0&&(o.words[o.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return s(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return s(typeof t=="number"),s(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(s(typeof t=="number"),s(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var o=(t.words[d]|0)*r;c-=o&67108863,v=(c>>26)-(o/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(s(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var o=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=o+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,o);b.negative===0&&(a=b,e&&(e.words[o]=1));for(var _=o-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(s(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){s(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){s(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),o=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++o;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(o)}},f.prototype._invmp=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,o=1;!(r.words[0]&o)&&v<26;++v,o<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){s(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),s(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return s(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return s(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else s(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){s(t.negative===0,"red works only with positives"),s(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){s((t.negative|r.negative)===0,"red works only with positives"),s(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(s(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);s(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),o=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,o).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();s(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,o=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){o=0;continue}v<<=1,v|=_,o++,!(o!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),o=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Ft)}(W0);var V2=W0.exports,V0,Co;function Y2(){if(Co)return V0;Co=1;var h=k0(),n=V2;V0=function(g){return new s(g)};var u={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};u.p224=u.secp224r1,u.p256=u.secp256r1=u.prime256v1,u.p192=u.secp192r1=u.prime192v1,u.p384=u.secp384r1,u.p521=u.secp521r1;function s(f){this.curveType=u[f],this.curveType||(this.curveType={name:f}),this.curve=new h.ec(this.curveType.name),this.keys=void 0}s.prototype.generateKeys=function(f,g){return this.keys=this.curve.genKeyPair(),this.getPublicKey(f,g)},s.prototype.computeSecret=function(f,g,y){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var S=this.curve.keyFromPublic(f).getPublic(),B=S.mul(this.keys.getPrivate()).getX();return m(B,y,this.curveType.byteLength)},s.prototype.getPublicKey=function(f,g){var y=this.keys.getPublic(g==="compressed",!0);return g==="hybrid"&&(y[y.length-1]%2?y[0]=7:y[0]=6),m(y,f)},s.prototype.getPrivateKey=function(f){return m(this.keys.getPrivate(),f)},s.prototype.setPublicKey=function(f,g){return g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g)),this.keys._importPublic(f),this},s.prototype.setPrivateKey=function(f,g){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var y=new n(f);return y=y.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(y),this};function m(f,g,y){Array.isArray(f)||(f=f.toArray());var S=new mt(f);if(y&&S.length<y){var B=new mt(y-S.length);B.fill(0),S=mt.concat([B,S])}return g?S.toString(g):S}return V0}var Fo={},J2=Ki,Y0=zt.Buffer,qo=function(h,n){for(var u=Y0.alloc(0),s=0,m;u.length<n;)m=G2(s++),u=Y0.concat([u,J2("sha1").update(h).update(m).digest()]);return u.slice(0,n)};function G2(h){var n=Y0.allocUnsafe(4);return n.writeUInt32BE(h,0),n}var Po=function(n,u){for(var s=n.length,m=-1;++m<s;)n[m]^=u[m];return n},J0={exports:{}};J0.exports,function(h){(function(n,u){function s(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:u.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=Ne.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),s(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(s(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(s(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var o=t.length-r;for(a=o%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,o=Math.min(c,c-v)+i,e=0,l=i;l<o;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){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"],x=[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],I=[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];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],o=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-o.length]+o+i:i=o+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}s(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return s(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);s(a<=d,"byte array longer than desired length"),s(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),o,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)o=l.andln(255),l.iushrn(8),v[e]=o;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)o=l.andln(255),l.iushrn(8),v[d-e-1]=o}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return s((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return s((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return s((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){s(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){s(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,o=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=o>>>26,b=o&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,o=l|0}return o!==0?r.words[e]=o|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,o,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Nt=a[5]|0,et=Nt&8191,pt=Nt>>>13,Dt=a[6]|0,j=Dt&8191,dt=Dt>>>13,Pt=a[7]|0,Q=Pt&8191,ct=Pt>>>13,Ot=a[8]|0,E=Ot&8191,w=Ot>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,Ht=d[3]|0,nt=Ht&8191,bt=Ht>>>13,Zt=d[4]|0,ft=Zt&8191,yt=Zt>>>13,Wt=d[5]|0,at=Wt&8191,wt=Wt>>>13,Vt=d[6]|0,ht=Vt&8191,Mt=Vt>>>13,Yt=d[7]|0,st=Yt&8191,xt=Yt>>>13,Jt=d[8]|0,ot=Jt&8191,_t=Jt>>>13,Gt=d[9]|0,ut=Gt&8191,St=Gt>>>13;i.negative=t.negative^r.negative,i.length=19,o=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var $t=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,o=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),o=o+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var Ut=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,o=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),o=o+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,o=o+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,o=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),o=o+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,o=o+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,o=o+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,o=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),o=o+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,o=o+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,o=o+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,o=o+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,o=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),o=o+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,o=o+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,o=o+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,o=o+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,o=o+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,o=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),o=o+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,o=o+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,o=o+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,o=o+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,o=o+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,o=o+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,o=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),o=o+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,o=o+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,o=o+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,o=o+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,o=o+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,o=o+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,o=o+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,o=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),o=o+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,o=o+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,o=o+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,o=o+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,o=o+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,o=o+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,o=o+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,o=o+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,o=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),o=o+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,o=o+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,o=o+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,o=o+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,o=o+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,o=o+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,o=o+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,o=o+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,o=o+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,o=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),o=o+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,o=o+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,o=o+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,o=o+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,o=o+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,o=o+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,o=o+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,o=o+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,o=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),o=o+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,o=o+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,o=o+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,o=o+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,o=o+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,o=o+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,o=o+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,o=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),o=o+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,o=o+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,o=o+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,o=o+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,o=o+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,o=o+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,o=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),o=o+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,o=o+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,o=o+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,o=o+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,o=o+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,o=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),o=o+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,o=o+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,o=o+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,o=o+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,o=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),o=o+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,o=o+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,o=o+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,o=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),o=o+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,o=o+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,o=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),o=o+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+o|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,o=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+o|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=$t,c[1]=Ut,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,o=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=o;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var o=v<<1,e=Math.cos(2*Math.PI/o),l=Math.sin(2*Math.PI/o),b=0;b<d;b+=o)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==o&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;s(d===0),s((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),o=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,o,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=o[q]*b[q]-e[q]*_[q];e[q]=o[q]*_[q]+e[q]*b[q],o[q]=O}return this.conjugate(o,e,a),this.transform(o,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){s(typeof t=="number"),s(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,o=(this.words[d]|0)-v<<r;this.words[d]=o|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return s(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){s(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,o=i;if(a-=c,a=Math.max(0,a),o){for(var e=0;e<c;e++)o.words[e]=this.words[e];o.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return o&&l!==0&&(o.words[o.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return s(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return s(typeof t=="number"),s(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(s(typeof t=="number"),s(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var o=(t.words[d]|0)*r;c-=o&67108863,v=(c>>26)-(o/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(s(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var o=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=o+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,o);b.negative===0&&(a=b,e&&(e.words[o]=1));for(var _=o-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(s(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){s(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){s(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),o=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++o;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(o)}},f.prototype._invmp=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,o=1;!(r.words[0]&o)&&v<26;++v,o<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){s(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),s(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return s(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return s(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else s(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){s(t.negative===0,"red works only with positives"),s(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){s((t.negative|r.negative)===0,"red works only with positives"),s(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(s(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);s(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),o=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,o).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();s(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,o=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){o=0;continue}v<<=1,v|=_,o++,!(o!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),o=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(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)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Ft)}(J0);var G0=J0.exports,Do=G0,X2=zt.Buffer;function j2(h,n){return X2.from(h.toRed(Do.mont(n.modulus)).redPow(new Do(n.publicExponent)).fromRed().toArray())}var No=j2,Q2=lf,X0=li,tm=Ki,$o=qo,Uo=Po,j0=G0,em=No,rm=l0,sr=zt.Buffer,im=function(n,u,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=Q2(n),g;if(m===4)g=nm(f,u);else if(m===1)g=fm(f,u,s);else if(m===3){if(g=new j0(u),g.cmp(f.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return s?rm(g,f):em(g,f)};function nm(h,n){var u=h.modulus.byteLength(),s=n.length,m=tm("sha1").update(sr.alloc(0)).digest(),f=m.length,g=2*f;if(s>u-g-2)throw new Error("message too long");var y=sr.alloc(u-s-g-2),S=u-f-1,B=X0(f),M=Uo(sr.concat([m,y,sr.alloc(1,1),n],S),$o(B,S)),x=Uo(B,$o(M,f));return new j0(sr.concat([sr.alloc(1),x,M],u))}function fm(h,n,u){var s=n.length,m=h.modulus.byteLength();if(s>m-11)throw new Error("message too long");var f;return u?f=sr.alloc(m-s-3,255):f=am(m-s-3),new j0(sr.concat([sr.from([0,u?1:2]),f,sr.alloc(1),n],m))}function am(h){for(var n=sr.allocUnsafe(h),u=0,s=X0(h*2),m=0,f;u<h;)m===s.length&&(s=X0(h*2),m=0),f=s[m++],f&&(n[u++]=f);return n}var hm=lf,Lo=qo,Oo=Po,zo=G0,sm=l0,om=Ki,um=No,on=zt.Buffer,lm=function(n,u,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=hm(n),g=f.modulus.byteLength();if(u.length>g||new zo(u).cmp(f.modulus)>=0)throw new Error("decryption error");var y;s?y=um(new zo(u),f):y=sm(u,f);var S=on.alloc(g-y.length);if(y=on.concat([S,y],g),m===4)return dm(f,y);if(m===1)return cm(f,y,s);if(m===3)return y;throw new Error("unknown padding")};function dm(h,n){var u=h.modulus.byteLength(),s=om("sha1").update(on.alloc(0)).digest(),m=s.length;if(n[0]!==0)throw new Error("decryption error");var f=n.slice(1,m+1),g=n.slice(m+1),y=Oo(f,Lo(g,m)),S=Oo(g,Lo(y,u-m-1));if(vm(s,S.slice(0,m)))throw new Error("decryption error");for(var B=m;S[B]===0;)B++;if(S[B++]!==1)throw new Error("decryption error");return S.slice(B)}function cm(h,n,u){for(var s=n.slice(0,2),m=2,f=0;n[m++]!==0;)if(m>=n.length){f++;break}var g=n.slice(2,m-1);if((s.toString("hex")!=="0002"&&!u||s.toString("hex")!=="0001"&&u)&&f++,g.length<8&&f++,f)throw new Error("decryption error");return n.slice(m)}function vm(h,n){h=on.from(h),n=on.from(n);var u=0,s=h.length;h.length!==n.length&&(u++,s=Math.min(h.length,n.length));for(var m=-1;++m<s;)u+=h[m]^n[m];return u}(function(h){h.publicEncrypt=im,h.privateDecrypt=lm,h.privateEncrypt=function(u,s){return h.publicEncrypt(u,s,!0)},h.publicDecrypt=function(u,s){return h.privateDecrypt(u,s,!0)}})(Fo);var un={};function Ko(){throw new Error(`secure random number generation not supported by this browser
|
|
16
16
|
use chrome, FireFox or Internet Explorer 11`)}var Ho=zt,Zo=li,Wo=Ho.Buffer,Vo=Ho.kMaxLength,Q0=Ft.crypto||Ft.msCrypto,Yo=Math.pow(2,32)-1;function Jo(h,n){if(typeof h!="number"||h!==h)throw new TypeError("offset must be a number");if(h>Yo||h<0)throw new TypeError("offset must be a uint32");if(h>Vo||h>n)throw new RangeError("offset out of range")}function Go(h,n,u){if(typeof h!="number"||h!==h)throw new TypeError("size must be a number");if(h>Yo||h<0)throw new TypeError("size must be a uint32");if(h+n>u||h>Vo)throw new RangeError("buffer too small")}Q0&&Q0.getRandomValues||!ye.browser?(un.randomFill=pm,un.randomFillSync=mm):(un.randomFill=Ko,un.randomFillSync=Ko);function pm(h,n,u,s){if(!Wo.isBuffer(h)&&!(h instanceof Ft.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof n=="function")s=n,n=0,u=h.length;else if(typeof u=="function")s=u,u=h.length-n;else if(typeof s!="function")throw new TypeError('"cb" argument must be a function');return Jo(n,h.length),Go(u,n,h.length),Xo(h,n,u,s)}function Xo(h,n,u,s){if(ye.browser){var m=h.buffer,f=new Uint8Array(m,n,u);if(Q0.getRandomValues(f),s){ye.nextTick(function(){s(null,h)});return}return h}if(s){Zo(u,function(y,S){if(y)return s(y);S.copy(h,n),s(null,h)});return}var g=Zo(u);return g.copy(h,n),h}function mm(h,n,u){if(typeof n=="undefined"&&(n=0),!Wo.isBuffer(h)&&!(h instanceof Ft.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Jo(n,h.length),u===void 0&&(u=h.length-n),Go(u,n,h.length),Xo(h,n,u)}var jo;function Qo(){if(jo)return Lt;jo=1,Lt.randomBytes=Lt.rng=Lt.pseudoRandomBytes=Lt.prng=li,Lt.createHash=Lt.Hash=Ki,Lt.createHmac=Lt.Hmac=La;var h=Td,n=Object.keys(h),u=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);Lt.getHashes=function(){return u};var s=_n;Lt.pbkdf2=s.pbkdf2,Lt.pbkdf2Sync=s.pbkdf2Sync;var m=rr;Lt.Cipher=m.Cipher,Lt.createCipher=m.createCipher,Lt.Cipheriv=m.Cipheriv,Lt.createCipheriv=m.createCipheriv,Lt.Decipher=m.Decipher,Lt.createDecipher=m.createDecipher,Lt.Decipheriv=m.Decipheriv,Lt.createDecipheriv=m.createDecipheriv,Lt.getCiphers=m.getCiphers,Lt.listCiphers=m.listCiphers;var f=R1();Lt.DiffieHellmanGroup=f.DiffieHellmanGroup,Lt.createDiffieHellmanGroup=f.createDiffieHellmanGroup,Lt.getDiffieHellman=f.getDiffieHellman,Lt.createDiffieHellman=f.createDiffieHellman,Lt.DiffieHellman=f.DiffieHellman;var g=W2();Lt.createSign=g.createSign,Lt.Sign=g.Sign,Lt.createVerify=g.createVerify,Lt.Verify=g.Verify,Lt.createECDH=Y2();var y=Fo;Lt.publicEncrypt=y.publicEncrypt,Lt.privateEncrypt=y.privateEncrypt,Lt.publicDecrypt=y.publicDecrypt,Lt.privateDecrypt=y.privateDecrypt;var S=un;return Lt.randomFill=S.randomFill,Lt.randomFillSync=S.randomFillSync,Lt.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
|
|
17
17
|
we accept pull requests
|
|
18
|
-
https://github.com/browserify/crypto-browserify`)},Lt.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},Lt}var gm=Qo();const bm=ke(gm);function ta(h){const n=bm.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function tu(h,n){const u=ta(h);let s=0;for(const m of n.variants)if(s+=m.weight,u<s)return m.value;return null}function eu(h,n){const u=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!u)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:s,salt:m}=h;return ta(`${u}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return tu(`${u}.${s}`,m)}default:return null}}function ru(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?Mu(S,n):!1}else return aa(g,n)}))return null;const m=h.rollout?eu(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let ln={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function ym(h){ln=h}function iu(h){return`flagmint_${h}_flags`}function nu(h){return`flagmint_${h}_context`}function fu(h,n){try{const u=ln.getItem(iu(h));if(!u)return null;const s=JSON.parse(u);return Date.now()-s.ts>n?null:s.data}catch(u){return null}}function au(h,n){try{ln.setItem(iu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(u){}}function hu(h){try{const n=ln.getItem(nu(h));return n?JSON.parse(n):null}catch(n){return null}}function su(h,n){try{ln.setItem(nu(h),JSON.stringify(n))}catch(u){}}const wm=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:hu,loadCachedFlags:fu,saveCachedContext:su,saveCachedFlags:au,setCacheStorage:ym},Symbol.toStringTag,{value:"Module"})),Mm=24*60*60*1e3;function ou(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const xm=ou().rest,_m=ou().ws;class Sm{constructor(n){var u,s,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(u=n.enableOfflineCache)!=null?u:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=Mm,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:xm,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:_m,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:fu,saveFlags:au,loadContext:hu,saveContext:su},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return De(this,null,function*(){var u;
|
|
18
|
+
https://github.com/browserify/crypto-browserify`)},Lt.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},Lt}var gm=Qo();const bm=ke(gm);function ta(h){const n=bm.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function tu(h,n){const u=ta(h);let s=0;for(const m of n.variants)if(s+=m.weight,u<s)return m.value;return null}function eu(h,n){const u=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!u)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:s,salt:m}=h;return ta(`${u}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return tu(`${u}.${s}`,m)}default:return null}}function ru(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?Mu(S,n):!1}else return aa(g,n)}))return null;const m=h.rollout?eu(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let ln={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function ym(h){ln=h}function iu(h){return`flagmint_${h}_flags`}function nu(h){return`flagmint_${h}_context`}function fu(h,n){try{const u=ln.getItem(iu(h));if(!u)return null;const s=JSON.parse(u);return Date.now()-s.ts>n?null:s.data}catch(u){return null}}function au(h,n){try{ln.setItem(iu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(u){}}function hu(h){try{const n=ln.getItem(nu(h));return n?JSON.parse(n):null}catch(n){return null}}function su(h,n){try{ln.setItem(nu(h),JSON.stringify(n))}catch(u){}}const wm=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:hu,loadCachedFlags:fu,saveCachedContext:su,saveCachedFlags:au,setCacheStorage:ym},Symbol.toStringTag,{value:"Module"})),Mm=24*60*60*1e3;function ou(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const xm=ou().rest,_m=ou().ws;class Sm{constructor(n){var u,s,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(u=n.enableOfflineCache)!=null?u:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=Mm,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:xm,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:_m,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:fu,saveFlags:au,loadContext:hu,saveContext:su},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return De(this,null,function*(){var u;if(console.log("[FlagClient] Initialization started with options:",n),this.isInitialized){console.log("[FlagClient] Already initialized, skipping.");return}try{if(this.persistContext){const s=yield Promise.resolve(this.cacheAdapter.loadContext(this.apiKey));s&&(this.context=s)}if(this.enableOfflineCache){const s=yield Promise.resolve(this.cacheAdapter.loadFlags(this.apiKey,this.cacheTTL));s&&(this.flags=s,this.notifySubscribers())}yield this.setupTransport(n),this.isInitialized=!0,this.resolveReady()}catch(s){this.rejectReady(s),(u=this.onError)==null||u.call(this,s)}})}setupTransport(n){return De(this,null,function*(){var f;console.log("[FlagClient] setupTransport() started");const u=(f=n.transportMode)!=null?f:"auto",s=()=>De(this,null,function*(){console.log("[FlagClient] Initializing WebSocket transport...");const g=new fa(this.wsEndpoint,this.apiKey);return yield g.init(),console.log("[FlagClient] WebSocket transport initialized"),g}),m=()=>{const g=new na(this.restEndpoint,this.apiKey,this.context,{pollIntervalMs:12e5,maxBackoffMs:6e4,backoffMultiplier:2});return g.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via long polling:",y),this.updateFlags(y)}),g.init(),g};try{if(u==="websocket")this.transport=yield s();else if(u==="long-polling")this.transport=m();else try{this.transport=yield s()}catch(y){console.warn("[FlagClient] WebSocket failed, falling back to long polling"),this.transport=m()}console.log("[FlagClient] Fetching flags...");const g=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Initial flags fetched:",g),this.updateFlags(g),typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via transport:",y),this.updateFlags(y)}),this.resolveReady()}catch(g){throw console.error("[FlagClient] setupTransport error:",g),this.rejectReady(g),this.onError&&this.onError(g instanceof Error?g:new Error(String(g))),g}})}updateFlags(n){this.flags=n,this.enableOfflineCache&&Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,n)),this.notifySubscribers()}notifySubscribers(){this.subscribers.forEach(n=>{try{n(this.flags)}catch(u){console.error("[FlagClient] Error in subscriber callback:",u)}})}subscribe(n){return this.subscribers.add(n),n(this.flags),()=>{this.subscribers.delete(n)}}getFlags(){return df({},this.flags)}getFlag(n,u){var s;return(s=this.flags[n])!=null?s:u}updateContext(n){return De(this,null,function*(){var u;if(this.context=df(df({},this.context),n),console.log("[FlagClient] Context updated:",this.context),this.persistContext&&(yield Promise.resolve(this.cacheAdapter.saveContext(this.apiKey,this.context))),this.transport&&typeof this.transport.fetchFlags=="function")try{const s=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Context persisted:",this.context,s),this.updateFlags(s)}catch(s){console.error("[FlagClient] Error updating flags after context change:",s),(u=this.onError)==null||u.call(this,s)}})}destroy(){this.refreshIntervalId&&clearInterval(this.refreshIntervalId),this.subscribers.clear(),this.transport&&this.transport.destroy()}ready(){return De(this,null,function*(){return console.log("[FlagClient] Waiting for client to be ready..."),this.deferInitialization&&!this.isInitialized&&this.initializationOptions&&(console.log("[FlagClient] Deferred initialization triggered by ready() call"),yield this.initialize(this.initializationOptions)),this.readyPromise})}evaluateLocally(n,u){const s={};for(const m in n){const f=ru(n[m],u);f!==null&&(s[m]=f)}return s}}function uu(h){return`flagmint_${h}_flags`}function lu(h){return`flagmint_${h}_context`}let Fr=null;function Am(h){Fr=h}function Bm(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{const u=yield Fr.getItem(uu(h));if(!u)return null;const s=JSON.parse(u);return Date.now()-s.ts>n?null:s.data}catch(u){return null}})}function Em(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{yield Fr.setItem(uu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(u){}})}function km(h){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{const n=yield Fr.getItem(lu(h));return n?JSON.parse(n):null}catch(n){return null}})}function Im(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{yield Fr.setItem(lu(h),JSON.stringify(n))}catch(u){}})}const Rm=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:km,loadCachedFlags:Bm,saveCachedContext:Im,saveCachedFlags:Em,setAsyncCacheStorage:Am},Symbol.toStringTag,{value:"Module"}));typeof globalThis.Buffer=="undefined"&&(globalThis.Buffer=Ke.Buffer),ge.FlagClient=Sm,ge.LongPollingTransport=na,ge.WebSocketTransport=fa,ge.asyncCache=Rm,ge.evaluateFlagValue=ru,ge.evaluateRollout=eu,ge.hashToPercentage=ta,ge.pickVariant=tu,ge.syncCache=wm,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})});
|