UNPKG

@walletconnect/client

Version:
1 lines 134 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("WalletConnect",[],e):"object"==typeof exports?exports.WalletConnect=e():t.WalletConnect=e()}(this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=42)}([function(t,e,r){"use strict";(function(t){r.d(e,"f",(function(){return u})),r.d(e,"g",(function(){return a})),r.d(e,"i",(function(){return h})),r.d(e,"h",(function(){return c})),r.d(e,"b",(function(){return f})),r.d(e,"c",(function(){return l})),r.d(e,"e",(function(){return d})),r.d(e,"d",(function(){return p})),r.d(e,"o",(function(){return m})),r.d(e,"n",(function(){return g})),r.d(e,"p",(function(){return y})),r.d(e,"A",(function(){return v})),r.d(e,"z",(function(){return w})),r.d(e,"B",(function(){return _})),r.d(e,"v",(function(){return b})),r.d(e,"u",(function(){return M})),r.d(e,"s",(function(){return k})),r.d(e,"r",(function(){return A})),r.d(e,"t",(function(){return I})),r.d(e,"q",(function(){return R})),r.d(e,"m",(function(){return E})),r.d(e,"l",(function(){return T})),r.d(e,"k",(function(){return j})),r.d(e,"j",(function(){return x})),r.d(e,"x",(function(){return P})),r.d(e,"a",(function(){return U})),r.d(e,"y",(function(){return N})),r.d(e,"w",(function(){return q}));var n=r(14),i=r.n(n),o=r(37),s=r.n(o);function u(t){return new Uint8Array(t)}function a(t,e=!1){const r=t.toString("hex");return e?U(r):r}function h(t){return t.toString("utf8")}function c(t){return t.readUIntBE(0,t.length)}function f(t){return s()(t)}function l(t,e=!1){return a(f(t),e)}function d(t){return h(f(t))}function p(t){return c(f(t))}function m(e){return t.from(P(e),"hex")}function g(t){return u(m(t))}function y(t){return h(m(t))}function v(e){return t.from(e,"utf8")}function w(t){return u(v(t))}function _(t,e=!1){return a(v(t),e)}function b(t){return f(O(S(t)))}function M(t){return O(S(t))}function S(t){return B((t>>>0).toString(2))}function O(t){return new Uint8Array(C(t).map(t=>parseInt(t,2)))}function k(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function A(e){return t.isBuffer(e)}function I(t){return i.a.strict(t)&&!A(t)}function R(t){return!I(t)&&!A(t)&&void 0!==t.byteLength}function E(t){return A(t)?"buffer":I(t)?"typed-array":R(t)?"array-buffer":Array.isArray(t)?"array":typeof t}function T(t){return function(t){return!("string"!=typeof t||!new RegExp(/^[01]+$/).test(t))&&t.length%8==0}(t)?"binary":k(t)?"hex":"utf8"}function j(...e){return t.concat(e)}function x(...t){let e=[];return t.forEach(t=>e=e.concat(Array.from(t))),new Uint8Array([...e])}function C(t,e=8){const r=B(t).match(new RegExp(`.{${e}}`,"gi"));return Array.from(r||[])}function B(t,e=8,r="0"){return function(t,e,r="0"){return L(t,e,!0,r)}(t,function(t,e=8){const r=t%e;return r?(t-r)/e*e+e:t}(t.length,e),r)}function P(t){return t.replace(/^0x/,"")}function U(t){return t.startsWith("0x")?t:"0x"+t}function N(t){return(t=B(t=P(t),2))&&(t=U(t)),t}function q(t){const e=t.startsWith("0x");return t=(t=P(t)).startsWith("0")?t.substring(1):t,e?U(t):t}function L(t,e,r,n="0"){const i=e-t.length;let o=t;if(i>0){const e=n.repeat(i);o=r?e+t:t+e}return o}}).call(this,r(16).Buffer)},function(t,e,r){"use strict";var n=r(35),i=r(5),o=r(36);function s(t){return Object(o.a)(t)}function u(){const t=s();return t&&t.os?t.os:void 0}function a(){return!!u()&&(function(){const t=u();return!!t&&t.toLowerCase().includes("android")}()||function(){const t=u();return!!t&&(t.toLowerCase().includes("ios")||t.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1)}())}function h(){return!function(){const t=s();return!(!t||!t.name)&&"node"===t.name.toLowerCase()}()&&!!c()}i.getFromWindow,i.getFromWindowOrThrow,i.getDocumentOrThrow,i.getDocument,i.getNavigatorOrThrow;const c=i.getNavigator,f=(i.getLocationOrThrow,i.getLocation),l=(i.getCryptoOrThrow,i.getCrypto,i.getLocalStorageOrThrow,i.getLocalStorage);function d(){return n.getWindowMetadata()}const p=function(t){if("string"!=typeof t)throw new Error("Cannot safe json parse value of type "+typeof t);try{return JSON.parse(t)}catch(e){return t}},m=function(t){return"string"==typeof t?t:JSON.stringify(t)};function g(t,e){const r=m(e),n=l();n&&n.setItem(t,r)}function y(t){let e=null,r=null;const n=l();return n&&(r=n.getItem(t)),e=r?p(r):r,e}function v(t){const e=l();e&&e.removeItem(t)}const w=["session_request","session_update","exchange_key","connect","disconnect","display_uri","modal_closed","transport_open","transport_close","transport_error"],_=["eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","eth_signTypedData_v1","eth_signTypedData_v2","eth_signTypedData_v3","eth_signTypedData_v4","personal_sign","wallet_addEthereumChain","wallet_switchEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"];var b=r(11),M=r.n(b),S=r(0);function O(t){return S.b(new Uint8Array(t))}function k(t,e){return S.c(new Uint8Array(t),!e)}function A(t){return S.f(t).buffer}function I(t){return S.n(t).buffer}function R(t,e){const r=S.x(S.y(new M.a(t).toString(16)));return e?r:S.a(r)}var E=r(38);function T(t){return S.y(t)}const j=r(39).payloadId;function x(){return((t,e)=>{for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e})()}function C(t,e){return S.s(t,e)}function B(t){return void 0!==t.method}function P(t){return void 0!==t.result}function U(t){return void 0!==t.error}function N(t){return void 0!==t.event}function q(t){return w.includes(t)||t.startsWith("wc_")}function L(t){return!!t.method.startsWith("wc_")||!_.includes(t.method)}function D(t){t=Object(S.x)(t.toLowerCase());const e=Object(S.x)(Object(E.keccak_256)((r=t,S.A(r))));var r;let n="";for(let r=0;r<t.length;r++)parseInt(e[r],16)>7?n+=t[r].toUpperCase():n+=t[r];return Object(S.a)(n)}function W(t){var e,r,n;return(n=t)&&n.length&&!C(t[0])&&(t[0]=(e=t[0],S.B(e,!r))),t}function F(t){if(void 0!==t.type&&"0"!==t.type)return t;if(void 0===t.from||(!(e=t.from)||"0x"!==e.toLowerCase().substring(0,2)||!/^(0x)?[0-9a-f]{40}$/i.test(e)||!/^(0x)?[0-9a-f]{40}$/.test(e)&&!/^(0x)?[0-9A-F]{40}$/.test(e)&&e!==D(e)))throw new Error("Transaction object must include a valid 'from' value.");var e;function r(t){let e=t;var r;return("number"==typeof t||"string"==typeof t&&!function(t){return""===t||"string"==typeof t&&""===t.trim()}(t))&&(C(t)?"string"==typeof t&&(e=T(t)):e=R(t)),"string"==typeof e&&(r=e,e=S.w(S.a(r))),e}const n={from:T(t.from),to:void 0===t.to?void 0:T(t.to),gasPrice:void 0===t.gasPrice?"":r(t.gasPrice),gas:void 0===t.gas?void 0===t.gasLimit?"":r(t.gasLimit):r(t.gas),value:void 0===t.value?"":r(t.value),nonce:void 0===t.nonce?"":r(t.nonce),data:void 0===t.data?"":T(t.data)||"0x"},i=["gasPrice","gas","value","nonce"];return Object.keys(n).forEach(t=>{(void 0===n[t]||"string"==typeof n[t]&&!n[t].trim().length)&&i.includes(t)&&delete n[t]}),n}function Y(t){const e=t.message||"Failed or Rejected Request";let r=-32e3;if(t&&!t.code)switch(e){case"Parse error":r=-32700;break;case"Invalid request":r=-32600;break;case"Method not found":r=-32601;break;case"Invalid params":r=-32602;break;case"Internal error":r=-32603;break;default:r=-32e3}const n={code:r,message:e};return t.data&&(n.data=t.data),n}var z=r(15);function J(t){const e=-1!==t.indexOf("?")?t.indexOf("?"):void 0;return void 0!==e?t.substr(e):""}function $(t,e){let r=Z(t);return r=Object.assign(Object.assign({},r),e),t=function(t){return z.stringify(t)}(r)}function Z(t){return z.parse(t)}function K(t){return void 0!==t.bridge}function V(t){const e=t.indexOf(":"),r=-1!==t.indexOf("?")?t.indexOf("?"):void 0,n=t.substring(0,e);const i=function(t){const e=t.split("@");return{handshakeTopic:e[0],version:parseInt(e[1],10)}}(t.substring(e+1,r));const o=function(t){const e=Z(t);return{key:e.key||"",bridge:e.bridge||""}}(void 0!==r?t.substr(r):"");return Object.assign(Object.assign({protocol:n},i),o)}r.d(e,"g",(function(){return s})),r.d(e,"r",(function(){return a})),r.d(e,"m",(function(){return h})),r.d(e,"k",(function(){return f})),r.d(e,"i",(function(){return d})),r.d(e,"B",(function(){return g})),r.d(e,"j",(function(){return y})),r.d(e,"A",(function(){return v})),r.d(e,"v",(function(){return"WALLETCONNECT_DEEPLINK_CHOICE"})),r.d(e,"C",(function(){return _})),r.d(e,"b",(function(){return O})),r.d(e,"c",(function(){return k})),r.d(e,"d",(function(){return A})),r.d(e,"e",(function(){return I})),r.d(e,"f",(function(){return R})),r.d(e,"w",(function(){return W})),r.d(e,"x",(function(){return F})),r.d(e,"z",(function(){return j})),r.d(e,"D",(function(){return x})),r.d(e,"h",(function(){return Y})),r.d(e,"u",(function(){return K})),r.d(e,"y",(function(){return V})),r.d(e,"l",(function(){return J})),r.d(e,"a",(function(){return $})),r.d(e,"o",(function(){return B})),r.d(e,"q",(function(){return P})),r.d(e,"p",(function(){return U})),r.d(e,"n",(function(){return N})),r.d(e,"s",(function(){return q})),r.d(e,"t",(function(){return L}))},function(t,e,r){"use strict";r.d(e,"b",(function(){return 256})),r.d(e,"g",(function(){return 256})),r.d(e,"a",(function(){return"AES-CBC"})),r.d(e,"f",(function(){return"SHA-256"})),r.d(e,"e",(function(){return"HMAC"})),r.d(e,"i",(function(){return"SHA-256"})),r.d(e,"j",(function(){return"SHA-512"})),r.d(e,"h",(function(){return 512})),r.d(e,"d",(function(){return"encrypt"})),r.d(e,"c",(function(){return"decrypt"})),r.d(e,"k",(function(){return"sign"})),r.d(e,"l",(function(){return"verify"}))},function(t,e,r){"use strict";r.d(e,"b",(function(){return n})),r.d(e,"d",(function(){return i})),r.d(e,"c",(function(){return o})),r.d(e,"e",(function(){return s})),r.d(e,"f",(function(){return u})),r.d(e,"a",(function(){return a}));const n="INTERNAL_ERROR",i="SERVER_ERROR",o=[-32700,-32600,-32601,-32602,-32603],s=[-32e3,-32099],u={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"},[n]:{code:-32603,message:"Internal error"},[i]:{code:-32e3,message:"Server error"}},a=i},function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(50),e),i(r(51),e)},function(t,e,r){"use strict";function n(t){let e=void 0;return"undefined"!=typeof window&&void 0!==window[t]&&(e=window[t]),e}function i(t){const e=n(t);if(!e)throw new Error(t+" is not defined in Window");return e}Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalStorage=e.getLocalStorageOrThrow=e.getCrypto=e.getCryptoOrThrow=e.getLocation=e.getLocationOrThrow=e.getNavigator=e.getNavigatorOrThrow=e.getDocument=e.getDocumentOrThrow=e.getFromWindowOrThrow=e.getFromWindow=void 0,e.getFromWindow=n,e.getFromWindowOrThrow=i,e.getDocumentOrThrow=function(){return i("document")},e.getDocument=function(){return n("document")},e.getNavigatorOrThrow=function(){return i("navigator")},e.getNavigator=function(){return n("navigator")},e.getLocationOrThrow=function(){return i("location")},e.getLocation=function(){return n("location")},e.getCryptoOrThrow=function(){return i("crypto")},e.getCrypto=function(){return n("crypto")},e.getLocalStorageOrThrow=function(){return i("localStorage")},e.getLocalStorage=function(){return n("localStorage")}},function(t,e,r){"use strict";r.d(e,"b",(function(){return s})),r.d(e,"a",(function(){return u})),r.d(e,"c",(function(){return a})),r.d(e,"d",(function(){return h})),r.d(e,"e",(function(){return c})),r.d(e,"f",(function(){return f}));var n=r(4),i=r(2);async function o(t,e=i.a){return n.getSubtleCrypto().importKey("raw",t,function(t){return t===i.a?{length:i.b,name:i.a}:{hash:{name:i.f},name:i.e}}(e),!0,function(t){return t===i.a?[i.d,i.c]:[i.k,i.l]}(e))}async function s(t,e,r){const s=n.getSubtleCrypto(),u=await o(e,i.a),a=await s.encrypt({iv:t,name:i.a},u,r);return new Uint8Array(a)}async function u(t,e,r){const s=n.getSubtleCrypto(),u=await o(e,i.a),a=await s.decrypt({iv:t,name:i.a},u,r);return new Uint8Array(a)}async function a(t,e){const r=n.getSubtleCrypto(),s=await o(t,i.e),u=await r.sign({length:i.g,name:i.e},s,e);return new Uint8Array(u)}async function h(t,e){const r=n.getSubtleCrypto(),s=await o(t,i.e),u=await r.sign({length:i.h,name:i.e},s,e);return new Uint8Array(u)}async function c(t){const e=n.getSubtleCrypto(),r=await e.digest({name:i.i},t);return new Uint8Array(r)}async function f(t){const e=n.getSubtleCrypto(),r=await e.digest({name:i.j},t);return new Uint8Array(r)}},function(t,e,r){"use strict";r.d(e,"c",(function(){return i})),r.d(e,"a",(function(){return o})),r.d(e,"b",(function(){return s}));var n=r(3);function i(t){return n.c.includes(t)}function o(t){return Object.keys(n.f).includes(t)?n.f[t]:n.f[n.a]}function s(t){const e=Object.values(n.f).find(e=>e.code===t);return e||n.f[n.a]}},function(t,e,r){"use strict";var n=r(27);r.d(e,"randomBytes",(function(){return n.a}));var i=r(28);r.d(e,"aesCbcDecrypt",(function(){return i.a})),r.d(e,"aesCbcEncrypt",(function(){return i.b}));var o=r(29);r.d(e,"hmacSha256Sign",(function(){return o.a}));r(34),r(10),r(2)},function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));class n{}},function(t,e,r){"use strict";var n=r(30);r.o(n,"isConstantTime")&&r.d(e,"isConstantTime",(function(){return n.isConstantTime}));r(31);var i=r(32);r.o(i,"isConstantTime")&&r.d(e,"isConstantTime",(function(){return i.isConstantTime}));var o=r(33);r.d(e,"isConstantTime",(function(){return o.a}))},function(t,e,r){(function(t){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=r(45).Buffer}catch(t){}function u(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o<i;o++){var s=t.charCodeAt(o)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function a(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var u=t.charCodeAt(s)-48;i*=n,i+=u>=49?u-49+10:u>=17?u-17+10:u}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,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){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):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(n("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,s,u=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<u&67108863,this.words[o+1]=s>>>26-u&67108863,(u+=24)>=26&&(u-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<u&67108863,this.words[o+1]=s>>>26-u&67108863,(u+=24)>=26&&(u-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,o=0;for(r=t.length-6,n=0;r>=e;r-=6)i=u(t,r,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=u(t,e,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,u=Math.min(o,o-s)+r,h=0,c=r;c<u;c+=n)h=a(t,c,c+n,e),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==s){var f=1;for(h=a(t,c,t.length,e),c=0;c<s;c++)f*=e;this.imuln(f),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 e=0;e<this.length;e++)t.words[e]=this.words[e];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"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,u=67108863&s,a=s/67108864|0;r.words[0]=u;for(var h=1;h<n;h++){for(var c=a>>>26,f=67108863&a,l=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=l;d++){var p=h-d|0;c+=(s=(i=0|t.words[p])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[h]=0|f,a=0|c}return 0!==a?r.words[h]=0|a:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,s=0;s<this.length;s++){var u=this.words[s],a=(16777215&(u<<i|o)).toString(16);r=0!==(o=u>>>24-i&16777215)||s!==this.length-1?h[6-a.length]+a+r:a+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var l=c[t],d=f[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?m+r:h[l-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},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&&n(!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,e){return n(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,u,a="le"===e,h=new t(o),c=this.clone();if(a){for(u=0;!c.isZero();u++)s=c.andln(255),c.iushrn(8),h[u]=s;for(;u<o;u++)h[u]=0}else{for(u=0;u<o-i;u++)h[u]=0;for(u=0;!c.isZero();u++)s=c.andln(255),c.iushrn(8),h[o-u-1]=s}return h},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},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 e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},o.prototype.ior=function(t){return n(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 e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},o.prototype.iand=function(t){return n(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 e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},o.prototype.ixor=function(t){return n(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){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,u=e.words,a=r.words,h=0,c=0|s[0],f=8191&c,l=c>>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],_=8191&w,b=w>>>13,M=0|s[4],S=8191&M,O=M>>>13,k=0|s[5],A=8191&k,I=k>>>13,R=0|s[6],E=8191&R,T=R>>>13,j=0|s[7],x=8191&j,C=j>>>13,B=0|s[8],P=8191&B,U=B>>>13,N=0|s[9],q=8191&N,L=N>>>13,D=0|u[0],W=8191&D,F=D>>>13,Y=0|u[1],z=8191&Y,J=Y>>>13,$=0|u[2],Z=8191&$,K=$>>>13,V=0|u[3],H=8191&V,Q=V>>>13,X=0|u[4],G=8191&X,tt=X>>>13,et=0|u[5],rt=8191&et,nt=et>>>13,it=0|u[6],ot=8191&it,st=it>>>13,ut=0|u[7],at=8191&ut,ht=ut>>>13,ct=0|u[8],ft=8191&ct,lt=ct>>>13,dt=0|u[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(f,W))|0)+((8191&(i=(i=Math.imul(f,F))+Math.imul(l,W)|0))<<13)|0;h=((o=Math.imul(l,F))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,F))+Math.imul(m,W)|0,o=Math.imul(m,F);var yt=(h+(n=n+Math.imul(f,z)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(l,z)|0))<<13)|0;h=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,W),i=(i=Math.imul(y,F))+Math.imul(v,W)|0,o=Math.imul(v,F),n=n+Math.imul(p,z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,z)|0,o=o+Math.imul(m,J)|0;var vt=(h+(n=n+Math.imul(f,Z)|0)|0)+((8191&(i=(i=i+Math.imul(f,K)|0)+Math.imul(l,Z)|0))<<13)|0;h=((o=o+Math.imul(l,K)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(_,W),i=(i=Math.imul(_,F))+Math.imul(b,W)|0,o=Math.imul(b,F),n=n+Math.imul(y,z)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,z)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,K)|0;var wt=(h+(n=n+Math.imul(f,H)|0)|0)+((8191&(i=(i=i+Math.imul(f,Q)|0)+Math.imul(l,H)|0))<<13)|0;h=((o=o+Math.imul(l,Q)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(S,W),i=(i=Math.imul(S,F))+Math.imul(O,W)|0,o=Math.imul(O,F),n=n+Math.imul(_,z)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,K)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,K)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,Q)|0)+Math.imul(m,H)|0,o=o+Math.imul(m,Q)|0;var _t=(h+(n=n+Math.imul(f,G)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(l,G)|0))<<13)|0;h=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,F))+Math.imul(I,W)|0,o=Math.imul(I,F),n=n+Math.imul(S,z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(O,z)|0,o=o+Math.imul(O,J)|0,n=n+Math.imul(_,Z)|0,i=(i=i+Math.imul(_,K)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,K)|0,n=n+Math.imul(y,H)|0,i=(i=i+Math.imul(y,Q)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,Q)|0,n=n+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+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(l,rt)|0))<<13)|0;h=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(E,W),i=(i=Math.imul(E,F))+Math.imul(T,W)|0,o=Math.imul(T,F),n=n+Math.imul(A,z)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(I,z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,K)|0,n=n+Math.imul(_,H)|0,i=(i=i+Math.imul(_,Q)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,Q)|0,n=n+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,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var Mt=(h+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(l,ot)|0))<<13)|0;h=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(x,W),i=(i=Math.imul(x,F))+Math.imul(C,W)|0,o=Math.imul(C,F),n=n+Math.imul(E,z)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(T,z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,n=n+Math.imul(S,H)|0,i=(i=i+Math.imul(S,Q)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,Q)|0,n=n+Math.imul(_,G)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var St=(h+(n=n+Math.imul(f,at)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(l,at)|0))<<13)|0;h=((o=o+Math.imul(l,ht)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(P,W),i=(i=Math.imul(P,F))+Math.imul(U,W)|0,o=Math.imul(U,F),n=n+Math.imul(x,z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(E,Z)|0,i=(i=i+Math.imul(E,K)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,K)|0,n=n+Math.imul(A,H)|0,i=(i=i+Math.imul(A,Q)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,Q)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+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 Ot=(h+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(l,ft)|0))<<13)|0;h=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(q,W),i=(i=Math.imul(q,F))+Math.imul(L,W)|0,o=Math.imul(L,F),n=n+Math.imul(P,z)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(U,z)|0,o=o+Math.imul(U,J)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,K)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,K)|0,n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,Q)|0)+Math.imul(T,H)|0,o=o+Math.imul(T,Q)|0,n=n+Math.imul(A,G)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,n=n+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,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,lt)|0;var kt=(h+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(l,pt)|0))<<13)|0;h=((o=o+Math.imul(l,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(q,z),i=(i=Math.imul(q,J))+Math.imul(L,z)|0,o=Math.imul(L,J),n=n+Math.imul(P,Z)|0,i=(i=i+Math.imul(P,K)|0)+Math.imul(U,Z)|0,o=o+Math.imul(U,K)|0,n=n+Math.imul(x,H)|0,i=(i=i+Math.imul(x,Q)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,Q)|0,n=n+Math.imul(E,G)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(T,G)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(_,at)|0,i=(i=i+Math.imul(_,ht)|0)+Math.imul(b,at)|0,o=o+Math.imul(b,ht)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,lt)|0;var At=(h+(n=n+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)+(At>>>26)|0,At&=67108863,n=Math.imul(q,Z),i=(i=Math.imul(q,K))+Math.imul(L,Z)|0,o=Math.imul(L,K),n=n+Math.imul(P,H)|0,i=(i=i+Math.imul(P,Q)|0)+Math.imul(U,H)|0,o=o+Math.imul(U,Q)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,at)|0,i=(i=i+Math.imul(S,ht)|0)+Math.imul(O,at)|0,o=o+Math.imul(O,ht)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,lt)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,lt)|0;var It=(h+(n=n+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)+(It>>>26)|0,It&=67108863,n=Math.imul(q,H),i=(i=Math.imul(q,Q))+Math.imul(L,H)|0,o=Math.imul(L,Q),n=n+Math.imul(P,G)|0,i=(i=i+Math.imul(P,tt)|0)+Math.imul(U,G)|0,o=o+Math.imul(U,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ht)|0)+Math.imul(I,at)|0,o=o+Math.imul(I,ht)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(O,ft)|0,o=o+Math.imul(O,lt)|0;var Rt=(h+(n=n+Math.imul(_,pt)|0)|0)+((8191&(i=(i=i+Math.imul(_,mt)|0)+Math.imul(b,pt)|0))<<13)|0;h=((o=o+Math.imul(b,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(q,G),i=(i=Math.imul(q,tt))+Math.imul(L,G)|0,o=Math.imul(L,tt),n=n+Math.imul(P,rt)|0,i=(i=i+Math.imul(P,nt)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(E,at)|0,i=(i=i+Math.imul(E,ht)|0)+Math.imul(T,at)|0,o=o+Math.imul(T,ht)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(I,ft)|0,o=o+Math.imul(I,lt)|0;var Et=(h+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,mt)|0)+Math.imul(O,pt)|0))<<13)|0;h=((o=o+Math.imul(O,mt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(q,rt),i=(i=Math.imul(q,nt))+Math.imul(L,rt)|0,o=Math.imul(L,nt),n=n+Math.imul(P,ot)|0,i=(i=i+Math.imul(P,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,n=n+Math.imul(x,at)|0,i=(i=i+Math.imul(x,ht)|0)+Math.imul(C,at)|0,o=o+Math.imul(C,ht)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,lt)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,lt)|0;var Tt=(h+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;h=((o=o+Math.imul(I,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(q,ot),i=(i=Math.imul(q,st))+Math.imul(L,ot)|0,o=Math.imul(L,st),n=n+Math.imul(P,at)|0,i=(i=i+Math.imul(P,ht)|0)+Math.imul(U,at)|0,o=o+Math.imul(U,ht)|0,n=n+Math.imul(x,ft)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,lt)|0;var jt=(h+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,mt)|0)+Math.imul(T,pt)|0))<<13)|0;h=((o=o+Math.imul(T,mt)|0)+(i>>>13)|0)+(jt>>>26)|0,jt&=67108863,n=Math.imul(q,at),i=(i=Math.imul(q,ht))+Math.imul(L,at)|0,o=Math.imul(L,ht),n=n+Math.imul(P,ft)|0,i=(i=i+Math.imul(P,lt)|0)+Math.imul(U,ft)|0,o=o+Math.imul(U,lt)|0;var xt=(h+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,mt)|0)+Math.imul(C,pt)|0))<<13)|0;h=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(q,ft),i=(i=Math.imul(q,lt))+Math.imul(L,ft)|0,o=Math.imul(L,lt);var Ct=(h+(n=n+Math.imul(P,pt)|0)|0)+((8191&(i=(i=i+Math.imul(P,mt)|0)+Math.imul(U,pt)|0))<<13)|0;h=((o=o+Math.imul(U,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(h+(n=Math.imul(q,pt))|0)+((8191&(i=(i=Math.imul(q,mt))+Math.imul(L,pt)|0))<<13)|0;return h=((o=Math.imul(L,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,a[0]=gt,a[1]=yt,a[2]=vt,a[3]=wt,a[4]=_t,a[5]=bt,a[6]=Mt,a[7]=St,a[8]=Ot,a[9]=kt,a[10]=At,a[11]=It,a[12]=Rt,a[13]=Et,a[14]=Tt,a[15]=jt,a[16]=xt,a[17]=Ct,a[18]=Bt,0!==h&&(a[19]=h,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=l),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?l(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var u=67108863&n,a=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=a;h++){var c=o-h,f=(0|t.words[c])*(0|e.words[h]),l=67108863&f;u=67108863&(l=l+u|0),i+=(s=(s=s+(f/67108864|0)|0)+(l>>>26)|0)>>>26,s&=67108863}r.words[o]=u,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},m.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},m.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var u=s<<1,a=Math.cos(2*Math.PI/u),h=Math.sin(2*Math.PI/u),c=0;c<i;c+=u)for(var f=a,l=h,d=0;d<s;d++){var p=r[c+d],m=n[c+d],g=r[c+d+s],y=n[c+d+s],v=f*g-l*y;y=f*y+l*g,g=v,r[c+d]=p+g,n[c+d]=m+y,r[c+d+s]=p-g,n[c+d+s]=m-y,d!==u&&(v=a*f-h*l,l=a*l+h*f,f=v)}},m.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},m.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},m.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},m.prototype.convert13b=function(t,e,r,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)r[s]=0;n(0===o),n(0==(-8192&o))},m.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},m.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),u=new Array(n),a=new Array(n),h=new Array(n),c=new Array(n),f=new Array(n),l=r.words;l.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,h,n),this.transform(s,o,u,a,n,i),this.transform(h,o,c,f,n,i);for(var d=0;d<n;d++){var p=u[d]*c[d]-a[d]*f[d];a[d]=u[d]*f[d]+a[d]*c[d],u[d]=p}return this.conjugate(u,a,n),this.transform(u,a,l,o,n,i),this.conjugate(l,o,n),this.normalize13b(l,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),p(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){n("number"==typeof t),n(t<67108864);for(var e=0,r=0;r<this.length;r++){var i=(0|this.words[r])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,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 e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r},o.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var u=this.words[e]&o,a=(0|this.words[e])-u<<r;this.words[e]=a|s,s=u>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},o.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),u=67108863^67108863>>>o<<o,a=r;if(i-=s,i=Math.max(0,i),a){for(var h=0;h<s;h++)a.words[h]=this.words[h];a.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var c=0;for(h=this.length-1;h>=0&&(0!==c||h>=i);h--){var f=0|this.words[h];this.words[h]=c<<26-o|f>>>o,c=f&u}return a&&0!==c&&(a.words[a.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},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){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},o.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;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 n("number"==typeof t),n(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 e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},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,e,r){var i,o,s=t.length+r;this._expand(s);var u=0;for(i=0;i<t.length;i++){o=(0|this.words[i+r])+u;var a=(0|t.words[i])*e;u=((o-=67108863&a)>>26)-(a/67108864|0),this.words[i+r]=67108863&o}for(;i<this.length-r;i++)u=(o=(0|this.words[i+r])+u)>>26,this.words[i+r]=67108863&o;if(0===u)return this.strip();for(n(-1===u),u=0,i=0;i<this.length;i++)u=(o=-(0|this.words[i])+u)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var u,a=n.length-i.length;if("mod"!==e){(u=new o(null)).length=a+1,u.words=new Array(u.length);for(var h=0;h<u.length;h++)u.words[h]=0}var c=n.clone()._ishlnsubmul(i,1,a);0===c.negative&&(n=c,u&&(u.words[a]=1));for(var f=a-1;f>=0;f--){var l=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,f);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);u&&(u.words[f]=l)}return u&&u.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:u||null,mod:n}},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(u=this.neg().divmod(t,e),"mod"!==e&&(i=u.div.neg()),"div"!==e&&(s=u.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(u=this.divmod(t.neg(),e),"mod"!==e&&(i=u.div.neg()),{div:i,mod:u.mod}):0!=(this.negative&t.negative)?(u=this.neg().divmod(t.neg(),e),"div"!==e&&(s=u.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:u.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{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,e);var i,s,u},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 e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},o.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),u=new o(0),a=new o(1),h=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++h;for(var c=r.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(c),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(r.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(u.isOdd()||a.isOdd())&&(u.iadd(c),a.isub(f)),u.iushrn(1),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(u),s.isub(a)):(r.isub(e),u.isub(i),a.isub(s))}return{a:u,b:a,gcd:r.iushln(h)}},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),u=new o(0),a=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var h=0,c=1;0==(e.words[0]&c)&&h<26;++h,c<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(r.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(r.iushrn(f);f-- >0;)u.isOdd()&&u.iadd(a),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(u)):(r.isub(e),u.isub(s))}return(i=0===e.cmpn(1)?s:u).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 e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},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){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,s=r;0!==o&&s<this.length;s++){var u=0|this.words[s];o=(u+=o)>>>26,u&=67108863,this.words[s]=u}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},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 M(t)},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return n(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 n(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with