@walletconnect/socket-transport
Version:
Socket Transport for WalletConnect
1 lines • 119 kB
JavaScript
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("WalletConnectSocketTransport",[],r):"object"==typeof exports?exports.WalletConnectSocketTransport=r():t.WalletConnectSocketTransport=r()}(this,(function(){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=27)}([function(t,r,n){"use strict";(function(t){n.d(r,"f",(function(){return s})),n.d(r,"g",(function(){return a})),n.d(r,"i",(function(){return h})),n.d(r,"h",(function(){return f})),n.d(r,"b",(function(){return c})),n.d(r,"c",(function(){return l})),n.d(r,"e",(function(){return d})),n.d(r,"d",(function(){return p})),n.d(r,"n",(function(){return m})),n.d(r,"m",(function(){return g})),n.d(r,"o",(function(){return y})),n.d(r,"z",(function(){return v})),n.d(r,"y",(function(){return w})),n.d(r,"A",(function(){return M})),n.d(r,"u",(function(){return b})),n.d(r,"t",(function(){return _})),n.d(r,"r",(function(){return O})),n.d(r,"q",(function(){return E})),n.d(r,"s",(function(){return k})),n.d(r,"p",(function(){return x})),n.d(r,"l",(function(){return T})),n.d(r,"k",(function(){return R})),n.d(r,"j",(function(){return B})),n.d(r,"w",(function(){return I})),n.d(r,"a",(function(){return j})),n.d(r,"x",(function(){return L})),n.d(r,"v",(function(){return N}));var e=n(9),i=n.n(e),o=n(24),u=n.n(o);function s(t){return new Uint8Array(t)}function a(t,r=!1){const n=t.toString("hex");return r?j(n):n}function h(t){return t.toString("utf8")}function f(t){return t.readUIntBE(0,t.length)}function c(t){return u()(t)}function l(t,r=!1){return a(c(t),r)}function d(t){return h(c(t))}function p(t){return f(c(t))}function m(r){return t.from(I(r),"hex")}function g(t){return s(m(t))}function y(t){return h(m(t))}function v(r){return t.from(r,"utf8")}function w(t){return s(v(t))}function M(t,r=!1){return a(v(t),r)}function b(t){return c(S(A(t)))}function _(t){return S(A(t))}function A(t){return C((t>>>0).toString(2))}function S(t){return new Uint8Array(P(t).map(t=>parseInt(t,2)))}function O(t,r){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!r||t.length===2+2*r)}function E(r){return t.isBuffer(r)}function k(t){return i.a.strict(t)&&!E(t)}function x(t){return!k(t)&&!E(t)&&void 0!==t.byteLength}function T(t){return E(t)?"buffer":k(t)?"typed-array":x(t)?"array-buffer":Array.isArray(t)?"array":typeof t}function R(t){return function(t){return!("string"!=typeof t||!new RegExp(/^[01]+$/).test(t))&&t.length%8==0}(t)?"binary":O(t)?"hex":"utf8"}function B(...r){return t.concat(r)}function P(t,r=8){const n=C(t).match(new RegExp(`.{${r}}`,"gi"));return Array.from(n||[])}function C(t,r=8,n="0"){return function(t,r,n="0"){return U(t,r,!0,n)}(t,function(t,r=8){const n=t%r;return n?(t-n)/r*r+r:t}(t.length,r),n)}function I(t){return t.replace(/^0x/,"")}function j(t){return t.startsWith("0x")?t:"0x"+t}function L(t){return(t=C(t=I(t),2))&&(t=j(t)),t}function N(t){const r=t.startsWith("0x");return t=(t=I(t)).startsWith("0")?t.substring(1):t,r?j(t):t}function U(t,r,n,e="0"){const i=r-t.length;let o=t;if(i>0){const r=e.repeat(i);o=n?r+t:t+r}return o}}).call(this,n(11).Buffer)},function(t,r,n){"use strict";n.d(r,"b",(function(){return e})),n.d(r,"d",(function(){return i})),n.d(r,"c",(function(){return o})),n.d(r,"e",(function(){return u})),n.d(r,"f",(function(){return s})),n.d(r,"a",(function(){return a}));const e="INTERNAL_ERROR",i="SERVER_ERROR",o=[-32700,-32600,-32601,-32602,-32603],u=[-32e3,-32099],s={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[e]:{code:-32603,message:"Internal error"},[i]:{code:-32e3,message:"Server error"}},a=i},function(t,r,n){"use strict";function e(t){let r=void 0;return"undefined"!=typeof window&&void 0!==window[t]&&(r=window[t]),r}function i(t){const r=e(t);if(!r)throw new Error(t+" is not defined in Window");return r}Object.defineProperty(r,"__esModule",{value:!0}),r.getLocalStorage=r.getLocalStorageOrThrow=r.getCrypto=r.getCryptoOrThrow=r.getLocation=r.getLocationOrThrow=r.getNavigator=r.getNavigatorOrThrow=r.getDocument=r.getDocumentOrThrow=r.getFromWindowOrThrow=r.getFromWindow=void 0,r.getFromWindow=e,r.getFromWindowOrThrow=i,r.getDocumentOrThrow=function(){return i("document")},r.getDocument=function(){return e("document")},r.getNavigatorOrThrow=function(){return i("navigator")},r.getNavigator=function(){return e("navigator")},r.getLocationOrThrow=function(){return i("location")},r.getLocation=function(){return e("location")},r.getCryptoOrThrow=function(){return i("crypto")},r.getCrypto=function(){return e("crypto")},r.getLocalStorageOrThrow=function(){return i("localStorage")},r.getLocalStorage=function(){return e("localStorage")}},function(t,r,n){"use strict";n.d(r,"c",(function(){return i})),n.d(r,"a",(function(){return o})),n.d(r,"b",(function(){return u}));var e=n(1);function i(t){return e.c.includes(t)}function o(t){return Object.keys(e.f).includes(t)?e.f[t]:e.f[e.a]}function u(t){const r=Object.values(e.f).find(r=>r.code===t);return r||e.f[e.a]}},function(t,r,n){"use strict";n.d(r,"a",(function(){return e}));class e{}},function(t,r,n){(function(t){!function(t,r){"use strict";function e(t,r){if(!t)throw new Error(r||"Assertion failed")}function i(t,r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}function o(t,r,n){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==r&&"be"!==r||(n=r,r=10),this._init(t||0,r||10,n||"be"))}var u;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{u=n(30).Buffer}catch(t){}function s(t,r,n){for(var e=0,i=Math.min(t.length,n),o=r;o<i;o++){var u=t.charCodeAt(o)-48;e<<=4,e|=u>=49&&u<=54?u-49+10:u>=17&&u<=22?u-17+10:15&u}return e}function a(t,r,n,e){for(var i=0,o=Math.min(t.length,n),u=r;u<o;u++){var s=t.charCodeAt(u)-48;i*=e,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,r){return t.cmp(r)>0?t:r},o.min=function(t,r){return t.cmp(r)<0?t:r},o.prototype._init=function(t,r,n){if("number"==typeof t)return this._initNumber(t,r,n);if("object"==typeof t)return this._initArray(t,r,n);"hex"===r&&(r=16),e(r===(0|r)&&r>=2&&r<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===r?this._parseHex(t,i):this._parseBase(t,r,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),r,n)},o.prototype._initNumber=function(t,r,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(t,r,n){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,u,s=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)u=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=u<<s&67108863,this.words[o+1]=u>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)u=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=u<<s&67108863,this.words[o+1]=u>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(t,r){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var e,i,o=0;for(n=t.length-6,e=0;n>=r;n-=6)i=s(t,n,n+6),this.words[e]|=i<<o&67108863,this.words[e+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,e++);n+6!==r&&(i=s(t,r,n+6),this.words[e]|=i<<o&67108863,this.words[e+1]|=i>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,r,n){this.words=[0],this.length=1;for(var e=0,i=1;i<=67108863;i*=r)e++;e--,i=i/r|0;for(var o=t.length-n,u=o%e,s=Math.min(o,o-u)+n,h=0,f=n;f<s;f+=e)h=a(t,f,f+e,r),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==u){var c=1;for(h=a(t,f,t.length,r),f=0;f<u;f++)c*=r;this.imuln(c),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}},o.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},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[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],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,r,n){n.negative=r.negative^t.negative;var e=t.length+r.length|0;n.length=e,e=e-1|0;var i=0|t.words[0],o=0|r.words[0],u=i*o,s=67108863&u,a=u/67108864|0;n.words[0]=s;for(var h=1;h<e;h++){for(var f=a>>>26,c=67108863&a,l=Math.min(h,r.length-1),d=Math.max(0,h-t.length+1);d<=l;d++){var p=h-d|0;f+=(u=(i=0|t.words[p])*(o=0|r.words[d])+c)/67108864|0,c=67108863&u}n.words[h]=0|c,a=0|f}return 0!==a?n.words[h]=0|a:n.length--,n.strip()}o.prototype.toString=function(t,r){var n;if(r=0|r||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,u=0;u<this.length;u++){var s=this.words[u],a=(16777215&(s<<i|o)).toString(16);n=0!==(o=s>>>24-i&16777215)||u!==this.length-1?h[6-a.length]+a+n:a+n,(i+=2)>=26&&(i-=26,u--)}for(0!==o&&(n=o.toString(16)+n);n.length%r!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var l=f[t],d=c[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:h[l-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%r!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}e(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,r){return e(void 0!==u),this.toArrayLike(u,t,r)},o.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},o.prototype.toArrayLike=function(t,r,n){var i=this.byteLength(),o=n||Math.max(1,i);e(i<=o,"byte array longer than desired length"),e(o>0,"Requested array length <= 0"),this.strip();var u,s,a="le"===r,h=new t(o),f=this.clone();if(a){for(s=0;!f.isZero();s++)u=f.andln(255),f.iushrn(8),h[s]=u;for(;s<o;s++)h[s]=0}else{for(s=0;s<o-i;s++)h[s]=0;for(s=0;!f.isZero();s++)u=f.andln(255),f.iushrn(8),h[o-s-1]=u}return h},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var r=t,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(t){if(0===t)return 26;var r=t,n=0;return 0==(8191&r)&&(n+=13,r>>>=13),0==(127&r)&&(n+=7,r>>>=7),0==(15&r)&&(n+=4,r>>>=4),0==(3&r)&&(n+=2,r>>>=2),0==(1&r)&&n++,n},o.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return 26*(this.length-1)+r},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(t+=n,26!==n)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.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()},o.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var r;r=this.length>t.length?t:this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&t.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var r,n;this.length>t.length?(r=this,n=t):(r=t,n=this);for(var e=0;e<n.length;e++)this.words[e]=r.words[e]^n.words[e];if(this!==r)for(;e<r.length;e++)this.words[e]=r.words[e];return this.length=r.length,this.strip()},o.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var r=0|Math.ceil(t/26),n=t%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,r){e("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=r?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(t){var r,n,e;if(0!==this.negative&&0===t.negative)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();this.length>t.length?(n=this,e=t):(n=t,e=this);for(var i=0,o=0;o<e.length;o++)r=(0|n.words[o])+(0|e.words[o])+i,this.words[o]=67108863&r,i=r>>>26;for(;0!==i&&o<n.length;o++)r=(0|n.words[o])+i,this.words[o]=67108863&r,i=r>>>26;if(this.length=n.length,0!==i)this.words[this.length]=i,this.length++;else if(n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this},o.prototype.add=function(t){var r;return 0!==t.negative&&0===this.negative?(t.negative=0,r=this.sub(t),t.negative^=1,r):0===t.negative&&0!==this.negative?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var n,e,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(n=this,e=t):(n=t,e=this);for(var o=0,u=0;u<e.length;u++)o=(r=(0|n.words[u])-(0|e.words[u])+o)>>26,this.words[u]=67108863&r;for(;0!==o&&u<n.length;u++)o=(r=(0|n.words[u])+o)>>26,this.words[u]=67108863&r;if(0===o&&u<n.length&&n!==this)for(;u<n.length;u++)this.words[u]=n.words[u];return this.length=Math.max(this.length,u),n!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,r,n){var e,i,o,u=t.words,s=r.words,a=n.words,h=0,f=0|u[0],c=8191&f,l=f>>>13,d=0|u[1],p=8191&d,m=d>>>13,g=0|u[2],y=8191&g,v=g>>>13,w=0|u[3],M=8191&w,b=w>>>13,_=0|u[4],A=8191&_,S=_>>>13,O=0|u[5],E=8191&O,k=O>>>13,x=0|u[6],T=8191&x,R=x>>>13,B=0|u[7],P=8191&B,C=B>>>13,I=0|u[8],j=8191&I,L=I>>>13,N=0|u[9],U=8191&N,W=N>>>13,D=0|s[0],F=8191&D,Y=D>>>13,q=0|s[1],z=8191&q,$=q>>>13,Z=0|s[2],H=8191&Z,J=Z>>>13,V=0|s[3],K=8191&V,Q=V>>>13,X=0|s[4],G=8191&X,tt=X>>>13,rt=0|s[5],nt=8191&rt,et=rt>>>13,it=0|s[6],ot=8191&it,ut=it>>>13,st=0|s[7],at=8191&st,ht=st>>>13,ft=0|s[8],ct=8191&ft,lt=ft>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;n.negative=t.negative^r.negative,n.length=19;var gt=(h+(e=Math.imul(c,F))|0)+((8191&(i=(i=Math.imul(c,Y))+Math.imul(l,F)|0))<<13)|0;h=((o=Math.imul(l,Y))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,e=Math.imul(p,F),i=(i=Math.imul(p,Y))+Math.imul(m,F)|0,o=Math.imul(m,Y);var yt=(h+(e=e+Math.imul(c,z)|0)|0)+((8191&(i=(i=i+Math.imul(c,$)|0)+Math.imul(l,z)|0))<<13)|0;h=((o=o+Math.imul(l,$)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(y,F),i=(i=Math.imul(y,Y))+Math.imul(v,F)|0,o=Math.imul(v,Y),e=e+Math.imul(p,z)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,z)|0,o=o+Math.imul(m,$)|0;var vt=(h+(e=e+Math.imul(c,H)|0)|0)+((8191&(i=(i=i+Math.imul(c,J)|0)+Math.imul(l,H)|0))<<13)|0;h=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(M,F),i=(i=Math.imul(M,Y))+Math.imul(b,F)|0,o=Math.imul(b,Y),e=e+Math.imul(y,z)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,z)|0,o=o+Math.imul(v,$)|0,e=e+Math.imul(p,H)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,J)|0;var wt=(h+(e=e+Math.imul(c,K)|0)|0)+((8191&(i=(i=i+Math.imul(c,Q)|0)+Math.imul(l,K)|0))<<13)|0;h=((o=o+Math.imul(l,Q)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(A,F),i=(i=Math.imul(A,Y))+Math.imul(S,F)|0,o=Math.imul(S,Y),e=e+Math.imul(M,z)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,$)|0,e=e+Math.imul(y,H)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,J)|0,e=e+Math.imul(p,K)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,Q)|0;var Mt=(h+(e=e+Math.imul(c,G)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(l,G)|0))<<13)|0;h=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(E,F),i=(i=Math.imul(E,Y))+Math.imul(k,F)|0,o=Math.imul(k,Y),e=e+Math.imul(A,z)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,z)|0,o=o+Math.imul(S,$)|0,e=e+Math.imul(M,H)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,J)|0,e=e+Math.imul(y,K)|0,i=(i=i+Math.imul(y,Q)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,Q)|0,e=e+Math.imul(p,G)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,G)|0,o=o+Math.imul(m,tt)|0;var bt=(h+(e=e+Math.imul(c,nt)|0)|0)+((8191&(i=(i=i+Math.imul(c,et)|0)+Math.imul(l,nt)|0))<<13)|0;h=((o=o+Math.imul(l,et)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(T,F),i=(i=Math.imul(T,Y))+Math.imul(R,F)|0,o=Math.imul(R,Y),e=e+Math.imul(E,z)|0,i=(i=i+Math.imul(E,$)|0)+Math.imul(k,z)|0,o=o+Math.imul(k,$)|0,e=e+Math.imul(A,H)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,H)|0,o=o+Math.imul(S,J)|0,e=e+Math.imul(M,K)|0,i=(i=i+Math.imul(M,Q)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,Q)|0,e=e+Math.imul(y,G)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,tt)|0,e=e+Math.imul(p,nt)|0,i=(i=i+Math.imul(p,et)|0)+Math.imul(m,nt)|0,o=o+Math.imul(m,et)|0;var _t=(h+(e=e+Math.imul(c,ot)|0)|0)+((8191&(i=(i=i+Math.imul(c,ut)|0)+Math.imul(l,ot)|0))<<13)|0;h=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(P,F),i=(i=Math.imul(P,Y))+Math.imul(C,F)|0,o=Math.imul(C,Y),e=e+Math.imul(T,z)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(R,z)|0,o=o+Math.imul(R,$)|0,e=e+Math.imul(E,H)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,J)|0,e=e+Math.imul(A,K)|0,i=(i=i+Math.imul(A,Q)|0)+Math.imul(S,K)|0,o=o+Math.imul(S,Q)|0,e=e+Math.imul(M,G)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,tt)|0,e=e+Math.imul(y,nt)|0,i=(i=i+Math.imul(y,et)|0)+Math.imul(v,nt)|0,o=o+Math.imul(v,et)|0,e=e+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,ut)|0;var At=(h+(e=e+Math.imul(c,at)|0)|0)+((8191&(i=(i=i+Math.imul(c,ht)|0)+Math.imul(l,at)|0))<<13)|0;h=((o=o+Math.imul(l,ht)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(j,F),i=(i=Math.imul(j,Y))+Math.imul(L,F)|0,o=Math.imul(L,Y),e=e+Math.imul(P,z)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,$)|0,e=e+Math.imul(T,H)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(R,H)|0,o=o+Math.imul(R,J)|0,e=e+Math.imul(E,K)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(k,K)|0,o=o+Math.imul(k,Q)|0,e=e+Math.imul(A,G)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,G)|0,o=o+Math.imul(S,tt)|0,e=e+Math.imul(M,nt)|0,i=(i=i+Math.imul(M,et)|0)+Math.imul(b,nt)|0,o=o+Math.imul(b,et)|0,e=e+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,ut)|0,e=e+Math.imul(p,at)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,at)|0,o=o+Math.imul(m,ht)|0;var St=(h+(e=e+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,lt)|0)+Math.imul(l,ct)|0))<<13)|0;h=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(U,F),i=(i=Math.imul(U,Y))+Math.imul(W,F)|0,o=Math.imul(W,Y),e=e+Math.imul(j,z)|0,i=(i=i+Math.imul(j,$)|0)+Math.imul(L,z)|0,o=o+Math.imul(L,$)|0,e=e+Math.imul(P,H)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,J)|0,e=e+Math.imul(T,K)|0,i=(i=i+Math.imul(T,Q)|0)+Math.imul(R,K)|0,o=o+Math.imul(R,Q)|0,e=e+Math.imul(E,G)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,tt)|0,e=e+Math.imul(A,nt)|0,i=(i=i+Math.imul(A,et)|0)+Math.imul(S,nt)|0,o=o+Math.imul(S,et)|0,e=e+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,ut)|0,e=e+Math.imul(y,at)|0,i=(i=i+Math.imul(y,ht)|0)+Math.imul(v,at)|0,o=o+Math.imul(v,ht)|0,e=e+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,lt)|0;var Ot=(h+(e=e+Math.imul(c,pt)|0)|0)+((8191&(i=(i=i+Math.imul(c,mt)|0)+Math.imul(l,pt)|0))<<13)|0;h=((o=o+Math.imul(l,mt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul(U,z),i=(i=Math.imul(U,$))+Math.imul(W,z)|0,o=Math.imul(W,$),e=e+Math.imul(j,H)|0,i=(i=i+Math.imul(j,J)|0)+Math.imul(L,H)|0,o=o+Math.imul(L,J)|0,e=e+Math.imul(P,K)|0,i=(i=i+Math.imul(P,Q)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,Q)|0,e=e+Math.imul(T,G)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,tt)|0,e=e+Math.imul(E,nt)|0,i=(i=i+Math.imul(E,et)|0)+Math.imul(k,nt)|0,o=o+Math.imul(k,et)|0,e=e+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,ut)|0,e=e+Math.imul(M,at)|0,i=(i=i+Math.imul(M,ht)|0)+Math.imul(b,at)|0,o=o+Math.imul(b,ht)|0,e=e+Math.imul(y,ct)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,lt)|0;var Et=(h+(e=e+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(U,H),i=(i=Math.imul(U,J))+Math.imul(W,H)|0,o=Math.imul(W,J),e=e+Math.imul(j,K)|0,i=(i=i+Math.imul(j,Q)|0)+Math.imul(L,K)|0,o=o+Math.imul(L,Q)|0,e=e+Math.imul(P,G)|0,i=(i=i+Math.imul(P,tt)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,tt)|0,e=e+Math.imul(T,nt)|0,i=(i=i+Math.imul(T,et)|0)+Math.imul(R,nt)|0,o=o+Math.imul(R,et)|0,e=e+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,ut)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,ut)|0,e=e+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ht)|0)+Math.imul(S,at)|0,o=o+Math.imul(S,ht)|0,e=e+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,lt)|0;var kt=(h+(e=e+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((o=o+Math.imul(v,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,e=Math.imul(U,K),i=(i=Math.imul(U,Q))+Math.imul(W,K)|0,o=Math.imul(W,Q),e=e+Math.imul(j,G)|0,i=(i=i+Math.imul(j,tt)|0)+Math.imul(L,G)|0,o=o+Math.imul(L,tt)|0,e=e+Math.imul(P,nt)|0,i=(i=i+Math.imul(P,et)|0)+Math.imul(C,nt)|0,o=o+Math.imul(C,et)|0,e=e+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,ut)|0,e=e+Math.imul(E,at)|0,i=(i=i+Math.imul(E,ht)|0)+Math.imul(k,at)|0,o=o+Math.imul(k,ht)|0,e=e+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ct)|0,o=o+Math.imul(S,lt)|0;var xt=(h+(e=e+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,mt)|0)+Math.imul(b,pt)|0))<<13)|0;h=((o=o+Math.imul(b,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,e=Math.imul(U,G),i=(i=Math.imul(U,tt))+Math.imul(W,G)|0,o=Math.imul(W,tt),e=e+Math.imul(j,nt)|0,i=(i=i+Math.imul(j,et)|0)+Math.imul(L,nt)|0,o=o+Math.imul(L,et)|0,e=e+Math.imul(P,ot)|0,i=(i=i+Math.imul(P,ut)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,ut)|0,e=e+Math.imul(T,at)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(R,at)|0,o=o+Math.imul(R,ht)|0,e=e+Math.imul(E,ct)|0,i=(i=i+Math.imul(E,lt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,lt)|0;var Tt=(h+(e=e+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;h=((o=o+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul(U,nt),i=(i=Math.imul(U,et))+Math.imul(W,nt)|0,o=Math.imul(W,et),e=e+Math.imul(j,ot)|0,i=(i=i+Math.imul(j,ut)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,ut)|0,e=e+Math.imul(P,at)|0,i=(i=i+Math.imul(P,ht)|0)+Math.imul(C,at)|0,o=o+Math.imul(C,ht)|0,e=e+Math.imul(T,ct)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(R,ct)|0,o=o+Math.imul(R,lt)|0;var Rt=(h+(e=e+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,mt)|0)+Math.imul(k,pt)|0))<<13)|0;h=((o=o+Math.imul(k,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(U,ot),i=(i=Math.imul(U,ut))+Math.imul(W,ot)|0,o=Math.imul(W,ut),e=e+Math.imul(j,at)|0,i=(i=i+Math.imul(j,ht)|0)+Math.imul(L,at)|0,o=o+Math.imul(L,ht)|0,e=e+Math.imul(P,ct)|0,i=(i=i+Math.imul(P,lt)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,lt)|0;var Bt=(h+(e=e+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(R,pt)|0))<<13)|0;h=((o=o+Math.imul(R,mt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,e=Math.imul(U,at),i=(i=Math.imul(U,ht))+Math.imul(W,at)|0,o=Math.imul(W,ht),e=e+Math.imul(j,ct)|0,i=(i=i+Math.imul(j,lt)|0)+Math.imul(L,ct)|0,o=o+Math.imul(L,lt)|0;var Pt=(h+(e=e+Math.imul(P,pt)|0)|0)+((8191&(i=(i=i+Math.imul(P,mt)|0)+Math.imul(C,pt)|0))<<13)|0;h=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,e=Math.imul(U,ct),i=(i=Math.imul(U,lt))+Math.imul(W,ct)|0,o=Math.imul(W,lt);var Ct=(h+(e=e+Math.imul(j,pt)|0)|0)+((8191&(i=(i=i+Math.imul(j,mt)|0)+Math.imul(L,pt)|0))<<13)|0;h=((o=o+Math.imul(L,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var It=(h+(e=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,mt))+Math.imul(W,pt)|0))<<13)|0;return h=((o=Math.imul(W,mt))+(i>>>13)|0)+(It>>>26)|0,It&=67108863,a[0]=gt,a[1]=yt,a[2]=vt,a[3]=wt,a[4]=Mt,a[5]=bt,a[6]=_t,a[7]=At,a[8]=St,a[9]=Ot,a[10]=Et,a[11]=kt,a[12]=xt,a[13]=Tt,a[14]=Rt,a[15]=Bt,a[16]=Pt,a[17]=Ct,a[18]=It,0!==h&&(a[19]=h,n.length++),n};function p(t,r,n){return(new m).mulp(t,r,n)}function m(t,r){this.x=t,this.y=r}Math.imul||(d=l),o.prototype.mulTo=function(t,r){var n=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,r):n<63?l(this,t,r):n<1024?function(t,r,n){n.negative=r.negative^t.negative,n.length=t.length+r.length;for(var e=0,i=0,o=0;o<n.length-1;o++){var u=i;i=0;for(var s=67108863&e,a=Math.min(o,r.length-1),h=Math.max(0,o-t.length+1);h<=a;h++){var f=o-h,c=(0|t.words[f])*(0|r.words[h]),l=67108863&c;s=67108863&(l=l+s|0),i+=(u=(u=u+(c/67108864|0)|0)+(l>>>26)|0)>>>26,u&=67108863}n.words[o]=s,e=u,u=i}return 0!==e?n.words[o]=e:n.length--,n.strip()}(this,t,r):p(this,t,r)},m.prototype.makeRBT=function(t){for(var r=new Array(t),n=o.prototype._countBits(t)-1,e=0;e<t;e++)r[e]=this.revBin(e,n,t);return r},m.prototype.revBin=function(t,r,n){if(0===t||t===n-1)return t;for(var e=0,i=0;i<r;i++)e|=(1&t)<<r-i-1,t>>=1;return e},m.prototype.permute=function(t,r,n,e,i,o){for(var u=0;u<o;u++)e[u]=r[t[u]],i[u]=n[t[u]]},m.prototype.transform=function(t,r,n,e,i,o){this.permute(o,t,r,n,e,i);for(var u=1;u<i;u<<=1)for(var s=u<<1,a=Math.cos(2*Math.PI/s),h=Math.sin(2*Math.PI/s),f=0;f<i;f+=s)for(var c=a,l=h,d=0;d<u;d++){var p=n[f+d],m=e[f+d],g=n[f+d+u],y=e[f+d+u],v=c*g-l*y;y=c*y+l*g,g=v,n[f+d]=p+g,e[f+d]=m+y,n[f+d+u]=p-g,e[f+d+u]=m-y,d!==s&&(v=a*c-h*l,l=a*l+h*c,c=v)}},m.prototype.guessLen13b=function(t,r){var n=1|Math.max(r,t),e=1&n,i=0;for(n=n/2|0;n;n>>>=1)i++;return 1<<i+1+e},m.prototype.conjugate=function(t,r,n){if(!(n<=1))for(var e=0;e<n/2;e++){var i=t[e];t[e]=t[n-e-1],t[n-e-1]=i,i=r[e],r[e]=-r[n-e-1],r[n-e-1]=-i}},m.prototype.normalize13b=function(t,r){for(var n=0,e=0;e<r/2;e++){var i=8192*Math.round(t[2*e+1]/r)+Math.round(t[2*e]/r)+n;t[e]=67108863&i,n=i<67108864?0:i/67108864|0}return t},m.prototype.convert13b=function(t,r,n,i){for(var o=0,u=0;u<r;u++)o+=0|t[u],n[2*u]=8191&o,o>>>=13,n[2*u+1]=8191&o,o>>>=13;for(u=2*r;u<i;++u)n[u]=0;e(0===o),e(0==(-8192&o))},m.prototype.stub=function(t){for(var r=new Array(t),n=0;n<t;n++)r[n]=0;return r},m.prototype.mulp=function(t,r,n){var e=2*this.guessLen13b(t.length,r.length),i=this.makeRBT(e),o=this.stub(e),u=new Array(e),s=new Array(e),a=new Array(e),h=new Array(e),f=new Array(e),c=new Array(e),l=n.words;l.length=e,this.convert13b(t.words,t.length,u,e),this.convert13b(r.words,r.length,h,e),this.transform(u,o,s,a,e,i),this.transform(h,o,f,c,e,i);for(var d=0;d<e;d++){var p=s[d]*f[d]-a[d]*c[d];a[d]=s[d]*c[d]+a[d]*f[d],s[d]=p}return this.conjugate(s,a,e),this.transform(s,a,l,o,e,i),this.conjugate(l,o,e),this.normalize13b(l,e),n.negative=t.negative^r.negative,n.length=t.length+r.length,n.strip()},o.prototype.mul=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},o.prototype.mulf=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),p(this,t,r)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){e("number"==typeof t),e(t<67108864);for(var r=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&r);r>>=26,r+=i/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var r=function(t){for(var r=new Array(t.bitLength()),n=0;n<r.length;n++){var e=n/26|0,i=n%26;r[n]=(t.words[e]&1<<i)>>>i}return r}(t);if(0===r.length)return new o(1);for(var n=this,e=0;e<r.length&&0===r[e];e++,n=n.sqr());if(++e<r.length)for(var i=n.sqr();e<r.length;e++,i=i.sqr())0!==r[e]&&(n=n.mul(i));return n},o.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var r,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var u=0;for(r=0;r<this.length;r++){var s=this.words[r]&o,a=(0|this.words[r])-s<<n;this.words[r]=a|u,u=s>>>26-n}u&&(this.words[r]=u,this.length++)}if(0!==i){for(r=this.length-1;r>=0;r--)this.words[r+i]=this.words[r];for(r=0;r<i;r++)this.words[r]=0;this.length+=i}return this.strip()},o.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,r,n){var i;e("number"==typeof t&&t>=0),i=r?(r-r%26)/26:0;var o=t%26,u=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,a=n;if(i-=u,i=Math.max(0,i),a){for(var h=0;h<u;h++)a.words[h]=this.words[h];a.length=u}if(0===u);else if(this.length>u)for(this.length-=u,h=0;h<this.length;h++)this.words[h]=this.words[h+u];else this.words[0]=0,this.length=1;var f=0;for(h=this.length-1;h>=0&&(0!==f||h>=i);h--){var c=0|this.words[h];this.words[h]=f<<26-o|c>>>o,f=c&s}return a&&0!==f&&(a.words[a.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,r,n){return e(0===this.negative),this.iushrn(t,r,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){e("number"==typeof t&&t>=0);var r=t%26,n=(t-r)/26,i=1<<r;return!(this.length<=n)&&!!(this.words[n]&i)},o.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var r=t%26,n=(t-r)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==r&&n++,this.length=Math.min(n,this.length),0!==r){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.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},o.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,r,n){var i,o,u=t.length+n;this._expand(u);var s=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+s;var a=(0|t.words[i])*r;s=((o-=67108863&a)>>26)-(a/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)s=(o=(0|this.words[i+n])+s)>>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(e(-1===s),s=0,i=0;i<this.length;i++)s=(o=-(0|this.words[i])+s)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,r){var n=(this.length,t.length),e=this.clone(),i=t,u=0|i.words[i.length-1];0!==(n=26-this._countBits(u))&&(i=i.ushln(n),e.iushln(n),u=0|i.words[i.length-1]);var s,a=e.length-i.length;if("mod"!==r){(s=new o(null)).length=a+1,s.words=new Array(s.length);for(var h=0;h<s.length;h++)s.words[h]=0}var f=e.clone()._ishlnsubmul(i,1,a);0===f.negative&&(e=f,s&&(s.words[a]=1));for(var c=a-1;c>=0;c--){var l=67108864*(0|e.words[i.length+c])+(0|e.words[i.length+c-1]);for(l=Math.min(l/u|0,67108863),e._ishlnsubmul(i,l,c);0!==e.negative;)l--,e.negative=0,e._ishlnsubmul(i,1,c),e.isZero()||(e.negative^=1);s&&(s.words[c]=l)}return s&&s.strip(),e.strip(),"div"!==r&&0!==n&&e.iushrn(n),{div:s||null,mod:e}},o.prototype.divmod=function(t,r,n){return e(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,r),"mod"!==r&&(i=s.div.neg()),"div"!==r&&(u=s.mod.neg(),n&&0!==u.negative&&u.iadd(t)),{div:i,mod:u}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),r),"mod"!==r&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),r),"div"!==r&&(u=s.mod.neg(),n&&0!==u.negative&&u.isub(t)),{div:s.div,mod:u}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===r?{div:this.divn(t.words[0]),mod:null}:"mod"===r?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,r);var i,u,s},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var n=0!==r.div.negative?r.mod.isub(t):r.mod,e=t.ushrn(1),i=t.andln(1),o=n.cmp(e);return o<0||1===i&&0===o?r.div:0!==r.div.negative?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(t){e(t<=67108863);for(var r=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(r*n+(0|this.words[i]))%t;return n},o.prototype.idivn=function(t){e(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*r;this.words[n]=i/t|0,r=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var r=this,n=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var i=new o(1),u=new o(0),s=new o(0),a=new o(1),h=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++h;for(var f=n.clone(),c=r.clone();!r.isZero();){for(var l=0,d=1;0==(r.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(i.isOdd()||u.isOdd())&&(i.iadd(f),u.isub(c)),i.iushrn(1),u.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(f),a.isub(c)),s.iushrn(1),a.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(s),u.isub(a)):(n.isub(r),s.isub(i),a.isub(u))}return{a:s,b:a,gcd:n.iushln(h)}},o.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var r=this,n=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var i,u=new o(1),s=new o(0),a=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,f=1;0==(r.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(r.iushrn(h);h-- >0;)u.isOdd()&&u.iadd(a),u.iushrn(1);for(var c=0,l=1;0==(n.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(n.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);r.cmp(n)>=0?(r.isub(n),u.isub(s)):(n.isub(r),s.isub(u))}return(i=0===r.cmpn(1)?u:s).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),n=t.clone();r.negative=0,n.negative=0;for(var e=0;r.isEven()&&n.isEven();e++)r.iushrn(1),n.iushrn(1);for(;;){for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var i=r.cmp(n);if(i<0){var o=r;r=n,n=o}else if(0===i||0===n.cmpn(1))break;r.isub(n)}return n.iushln(e)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){e("number"==typeof t);var r=t%26,n=(t-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,u=n;0!==o&&u<this.length;u++){var s=0|this.words[u];o=(s+=o)>>>26,s&=67108863,this.words[u]=s}return 0!==o&&(this.words[u]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var r,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)r=1;else{n&&(t=-t),e(t<=67108863,"Number is too big");var i=0|this.words[0];r=i===t?0:i<t?-1:1}return 0!==this.negative?0|-r:r},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var r=this.ucmp(t);return 0!==this.negative?0|-r:r},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var e=0|this.words[n],i=0|t.words[n];if(e!==i){e<i?r=-1:e>i&&(r=1);break}}return r},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new _(t)},o.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,r){this.name=t,this.p=new o(r,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function b(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var r=o._prime(t);this.m=r.p,this.prime=r}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var r,n=t;do{this.split(n,this.tmp),r=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(r>this.n);var e=r<this.n?-1:n.ucmp(this.p);return 0===e?(n.words[0]=0,n.length=1):e>0?n.isub(this.p):n.strip(),n},y.prototype.split=function(t,r){t.iushrn(this.n,0,r)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,r){for(var n=Math.min(t.length,9),e=0;e<n;e++)r.words[e]=t.words[e];if(r.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(r.words[r.length++]=4194303&i,e=10;e<t.length;e++){var o=0|t.words[e];t.words[e-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[e-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,n=0;n<t.length;n++){var e=0|t.words[n];r+=977*e,t.words[n]=67108863&r,r=64*e+(r/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(w,y),i(M,y),i(b,y),b.prototype.imulK=function(t){for(var r=0,n=0;n<t.length;n++){var e=19*(0|t.words[n])+r,i=67108863&e;e>>>=26,t.words[n]=i,r=e}return 0!==r&&(t.words[t.length++]=r),t},o._prime=function(t){if(g[t])return g[t];var r;if("k256"===t)r=new v;else if("p224"===t)r=new w;else if("p192"===t)r=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);r=new b}return g[t]=r,r},_.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,r){e(0==(t.negative|r.negative),"red works only with positives"),e(t.red&&t.red===r.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,r){this._verify2(t,r);var n=t.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},_.prototype.iadd=function(t,r){this._verify2(t,r);var n=t.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},_.prototype.sub=function(t,r){this._verify2(t,r);var n=t.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},_.prototype.isub=function(t,r){this._verify2(t,r);var n=t.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},_.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},_.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},_.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(e(r%2==1),3===r){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),u=0;!i.isZero()&&0===i.andln(1);)u++,i.iushrn(1);e(!i.isZero());var s=new o(1).toRed(this),a=s.redNeg(),h=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,h).cmp(a);)f.redIAdd(a);for(var c=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=u;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();e(g<p);var y=this.pow(c,new o(1).iushln(p-g-1));l=l.redMul(y),c=y.redSqr(),d=d.redMul(c),p=g}return l},_.prototype.invm=function(t){var r=t._invmp(this.m);return 0!==r.negative?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},_.prototype.pow=function(t,r){if(r.isZero())return new o(1).toRed(this);if(0===r.cmpn(1))return t.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=t;for(var e=2;e<n.length;e++)n[e]=this.mul(n[e-1],t);var i=n[0],u=0,s=0,a=r.bitLength()%26;for(0===a&&(a=26),e=r.length-1;e>=0;e--){for(var h=r.words[e],f=a-1;f>=0;f--){var c=h>>f&1;i!==n[0]&&(i=this.sqr(i)),0!==c||0!==u?(u<<=1,u|=c,(4===++s||0===e&&0===f)&&(i=this.mul(i,n[u]),s=0,u=0)):s=0}a=26}return i},_.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},_.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},o.mont=function(t){return new A(t)},i(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},A.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var n=t.imul(r),e=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(e).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new o(0)._forceRed(this);var n=t.mul(r),e=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(e).iushrn(this.shift),u=i;return i.cmp(this.m)>=0?u=i.isub(this.m):i.cmpn(0)<0&&(u=i.iadd(this.m)),u._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,n(29)(t))},function(t,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,r,n){"use strict";var e=this&&this.__createBinding||(Object.create?function(t,r,n,e){void 0===e&&(e=n),Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[n]}})}:function(t,r,n,e){void 0===e&&(e=n),t[e]=r[n]}),i=this&&this.__exportStar||function(t,r){for(var n in t)"default"===n||r.hasOwnProperty(n)||e(r,t,n)};Object.defineProperty(r,"__esModule",{value:!0}),i(n(35),r),i(n(36),r)},function(t,r){var n,e,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(r){try{return n.call(null,t,0)}