UNPKG

@kazeblockchain/kazejs

Version:

Javascript libraries for Kaze wallet

1 lines 488 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=164)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed8=t.sha256=t.hash256=t.hash160=t.StringStream=t.ensureHex=t.isHex=t.reverseHex=t.reverseArray=t.hexXor=t.num2VarInt=t.fixed82num=t.num2fixed8=t.num2hexstring=t.int2hex=t.hexstring2str=t.str2hexstring=t.ab2hexstring=t.hexstring2ab=t.str2ab=t.ab2str=void 0;var n=f(r(50)),i=f(r(49)),a=f(r(107)),o=f(r(106)),s=f(r(14));function f(e){return e&&e.__esModule?e:{default:e}}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e,t,r){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function l(e){return(l=Object.getPrototypeOf||function(e){return e.__proto__})(e)}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function b(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),e}function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var m=function(e){return String.fromCharCode.apply(null,new Uint8Array(e))};t.ab2str=m;var g=function(e){if("string"!=typeof e)throw new Error("str2ab expects a string");for(var t=new Uint8Array(e.length),r=0,n=e.length;r<n;r++)t[r]=e.charCodeAt(r);return t};t.str2ab=g;var y=function(e){if(A(e),!e.length)return new Uint8Array;for(var t=e.length/2,r=new Uint8Array(t),n=0;n<t;n++)r[n]=parseInt(e.substring(0,2),16),e=e.substring(2);return r};t.hexstring2ab=y;var w=function(e){if("object"!==v(e))throw new Error("ab2hexstring expects an array");for(var t="",r=0;r<e.length;r++){var n=e[r].toString(16);t+=n=0===n.length?"00":1===n.length?"0"+n:n}return t};t.ab2hexstring=w;t.str2hexstring=function(e){return w(g(e))};t.hexstring2str=function(e){return m(y(e))};t.int2hex=function(e){if("number"!=typeof e)throw new Error("int2hex expects a number");var t=e.toString(16);return t.length%2?"0"+t:t};var _=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("number"!=typeof e)throw new Error("num must be numeric");if(e<0)throw new RangeError("num is unsigned (>= 0)");if(t%1!=0)throw new Error("size must be a whole integer");if(!Number.isSafeInteger(e))throw new RangeError("num (".concat(e,") must be a safe integer"));t*=2;var n=e.toString(16);return n=n.length%t==0?n:("0".repeat(t)+n).substring(n.length),r&&(n=k(n)),n};t.num2hexstring=_;t.num2fixed8=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;if("number"!=typeof e)throw new Error("num must be numeric");if(t%1!=0)throw new Error("size must be a whole integer");return new E(e.toFixed(8)).toReverseHex().slice(0,2*t)};t.fixed82num=function(e){return A(e),""===e?0:E.fromReverseHex(e).toNumber()};t.num2VarInt=function(e){return e<253?_(e):e<=65535?"fd"+_(e,2,!0):e<=4294967295?"fe"+_(e,4,!0):"ff"+_(e,8,!0)};t.hexXor=function(e,t){if(A(e),A(t),e.length!==t.length)throw new Error("strings are disparate lengths");for(var r=[],n=0;n<e.length;n+=2)r.push(parseInt(e.substr(n,2),16)^parseInt(t.substr(n,2),16));return w(r)};t.reverseArray=function(e){if("object"!==v(e)||!e.length)throw new Error("reverseArray expects an array");for(var t=new Uint8Array(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};var k=function(e){A(e);for(var t="",r=e.length-2;r>=0;r-=2)t+=e.substr(r,2);return t};t.reverseHex=k;var x=/^([0-9A-Fa-f]{2})*$/,S=function(e){try{return x.test(e)}catch(e){return!1}};t.isHex=S;var A=function(e){if(!S(e))throw new Error("Expected a hexstring but got ".concat(e))};t.ensureHex=A;var M=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(this,e),this.str=t,this.pter=0}return b(e,[{key:"isEmpty",value:function(){return this.pter>=this.str.length}},{key:"peek",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.isEmpty()?"":this.substr(this.ptr,2*e)}},{key:"read",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(this.isEmpty())throw new Error;var t=this.str.substr(this.pter,2*e);return this.pter+=2*e,t}},{key:"readVarBytes",value:function(){return this.read(this.readVarInt())}},{key:"readVarInt",value:function(){var e=parseInt(this.read(1),16);return 253===e?e=parseInt(k(this.read(2)),16):254===e?e=parseInt(k(this.read(4)),16):255===e&&(e=parseInt(k(this.read(8)),16)),e}},{key:"reset",value:function(){this.pter=0}}]),e}();t.StringStream=M;t.hash160=function(e){if("string"!=typeof e)throw new Error("reverseHex expects a string");if(e.length%2!=0)throw new Error("Incorrect Length: ".concat(e));var t=n.default.parse(e),r=(0,i.default)(t);return(0,a.default)(r).toString()};t.hash256=function(e){if("string"!=typeof e)throw new Error("reverseHex expects a string");if(e.length%2!=0)throw new Error("Incorrect Length: ".concat(e));var t=n.default.parse(e),r=(0,i.default)(t);return(0,i.default)(r).toString()};t.sha256=function(e){if("string"!=typeof e)throw new Error("reverseHex expects a string");if(e.length%2!=0)throw new Error("Incorrect Length: ".concat(e));var t=n.default.parse(e);return(0,i.default)(t).toString()};var E=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return h(this,t),"number"==typeof e&&(e=e.toFixed(8)),u(this,l(t).call(this,e,r))}return b(t,[{key:"toHex",value:function(){var e=this.times(1e8).round(0).toString(16);return"0".repeat(16-e.length)+e}},{key:"toReverseHex",value:function(){return k(this.toHex())}},{key:s.default.inspect.custom,value:function(e,t){return this.toFixed(8)}},{key:"ceil",value:function(){return new t(d(l(t.prototype),"ceil",this).call(this))}},{key:"floor",value:function(){return new t(d(l(t.prototype),"floor",this).call(this))}},{key:"round",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new t(d(l(t.prototype),"round",this).call(this,e,r))}},{key:"div",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.dividedBy(e,t)}},{key:"dividedBy",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new t(d(l(t.prototype),"dividedBy",this).call(this,e,r))}},{key:"mul",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.times(e,t)}},{key:"times",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new t(d(l(t.prototype),"times",this).call(this,e,r))}},{key:"add",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.plus(e,t)}},{key:"plus",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new t(d(l(t.prototype),"plus",this).call(this,e,r))}},{key:"sub",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.minus(e,t)}},{key:"minus",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new t(d(l(t.prototype),"minus",this).call(this,e,r))}}],[{key:"fromHex",value:function(e){return new t(e,16).div(1e8)}},{key:"fromReverseHex",value:function(e){return this.fromHex(k(e))}}]),function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");c(e.prototype,t&&t.prototype),t&&c(e,t)}(t,e),t}(o.default);t.Fixed8=E},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logger=t.default=void 0;var n=a(r(88)),i=a(r(87));function a(e){return e&&e.__esModule?e:{default:e}}i.default.reg(n.default),n.default.setDefaultLevel("silent"),n.default.setAll=function(e){Object.keys(n.default.getLoggers()).map(function(t){n.default.getLogger(t).setLevel(e)})};var o=function(e,t){var r=(new Date).toUTCString();e=e.toUpperCase();var n=t;return"[".concat(r,"] (").concat(n,") ").concat(e,": ")};t.default=function(e){var t=n.default.getLogger(e);return i.default.apply(t,{format:o}),t};var s=n.default;t.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TX_VERSION=t.RPC_VERSION=t.NEP_FLAG=t.NEP_HEADER=t.KAZE_NETWORK=t.DEFAULT_ACCOUNT_CONTRACT=t.DEFAULT_WALLET=t.DEFAULT_SYSFEE=t.DEFAULT_SCRYPT=t.DEFAULT_REQ=t.DEFAULT_RPC=t.ASSET_ID=t.ASSETS=t.ADDR_VERSION=void 0;t.ADDR_VERSION="2d";t.ASSETS={Kaze:"KAZE",f1fee7945e5ba7fed56272b916094ed8f384a94e63d5f8d81214dfde489ffb17:"KAZE",Stream:"STREAM","9d2593e23db5e8946969a16d1980ee57e04bb25904bb0ca0d181257eb48a5398":"STREAM"};t.ASSET_ID={KAZE:"f1fee7945e5ba7fed56272b916094ed8f384a94e63d5f8d81214dfde489ffb17",STREAM:"9d2593e23db5e8946969a16d1980ee57e04bb25904bb0ca0d181257eb48a5398"};t.DEFAULT_RPC={MAIN:"https://node4.kaze.solutions:22886",TEST:"https://node4.kaze.solutions:44886"};t.DEFAULT_REQ={jsonrpc:"2.0",method:"getblockcount",params:[],id:1234};t.DEFAULT_SCRYPT={cost:16384,blockSize:8,parallel:8,size:64};t.DEFAULT_SYSFEE={enrollmentTransaction:10,issueTransaction:5,publishTransaction:5,registerTransaction:100};t.DEFAULT_WALLET={name:"myWallet",version:"1.0",scrypt:{},accounts:[],extra:null};t.DEFAULT_ACCOUNT_CONTRACT={script:"",parameters:[{name:"signature",type:"Signature"}],deployed:!1};t.KAZE_NETWORK={MAIN:"MainNet",TEST:"TestNet"};t.NEP_HEADER="0142";t.NEP_FLAG="e0";t.RPC_VERSION="2.3.2";t.TX_VERSION={CLAIM:0,CONTRACT:0,INVOCATION:1}},function(e,t,r){var n;e.exports=(n=n||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},i=n.lib={},a=i.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=i.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||f).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var a=0;a<i;a++){var o=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=o<<24-(n+a)%4*8}else for(var a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){var t=t,r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},a=0;a<t;a+=4){var s=i(4294967296*(r||e.random()));r=987654071*s(),n.push(4294967296*s()|0)}return new o.init(n,t)}}),s=n.enc={},f=s.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new o.init(r,t/2)}},c=s.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var a=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(a))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new o.init(r,t)}},u=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=u.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,a=this.blockSize,s=4*a,f=i/s,c=(f=t?e.ceil(f):e.max((0|f)-this._minBufferSize,0))*a,u=e.min(4*c,i);if(c){for(var d=0;d<c;d+=a)this._doProcessBlock(n,d);var l=n.splice(0,c);r.sigBytes-=u}return new o.init(l,u)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),l=(i.Hasher=d.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new l.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math),n)},function(e,t,r){"use strict";var n=t;n.version=r(130).version,n.utils=r(129),n.rand=r(128),n.curve=r(18),n.curves=r(122),n.ec=r(114),n.eddsa=r(110)},function(e,t,r){"use strict";var n=r(70),i=r(161),a=Object.prototype.toString;function o(e){return"[object Array]"===a.call(e)}function s(e){return null!==e&&"object"==typeof e}function f(e){return"[object Function]"===a.call(e)}function c(e,t){if(null!==e&&void 0!==e)if("object"!=typeof e&&(e=[e]),o(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===a.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===a.call(e)},isFile:function(e){return"[object File]"===a.call(e)},isBlob:function(e){return"[object Blob]"===a.call(e)},isFunction:f,isStream:function(e){return s(e)&&f(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:c,merge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]=r}for(var n=0,i=arguments.length;n<i;n++)c(arguments[n],r);return t},extend:function(e,t,r){return c(t,function(t,i){e[i]=r&&"function"==typeof t?n(t,r):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,r){"use strict";var n=r(9),i=r(17);function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function o(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16))}else for(var n=0;n<e.length;n++){var i=e.charCodeAt(n),a=i>>8,o=255&i;a?r.push(a,o):r.push(o)}else for(n=0;n<e.length;n++)r[n]=0|e[n];return r},t.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=o(e[r].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];"little"===t&&(i=a(i)),r+=s(i.toString(16))}return r},t.zero2=o,t.zero8=s,t.join32=function(e,t,r,i){var a=r-t;n(a%4==0);for(var o=new Array(a/4),s=0,f=t;s<o.length;s++,f+=4){var c;c="big"===i?e[f]<<24|e[f+1]<<16|e[f+2]<<8|e[f+3]:e[f+3]<<24|e[f+2]<<16|e[f+1]<<8|e[f],o[s]=c>>>0}return o},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n<e.length;n++,i+=4){var a=e[n];"big"===t?(r[i]=a>>>24,r[i+1]=a>>>16&255,r[i+2]=a>>>8&255,r[i+3]=255&a):(r[i+3]=a>>>24,r[i+2]=a>>>16&255,r[i+1]=a>>>8&255,r[i]=255&a)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],a=n+e[t+1]>>>0,o=(a<n?1:0)+r+i;e[t]=o>>>0,e[t+1]=a},t.sum64_hi=function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,a,o,s){var f=0,c=t;return f+=(c=c+n>>>0)<t?1:0,f+=(c=c+a>>>0)<a?1:0,e+r+i+o+(f+=(c=c+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,r,n,i,a,o,s){return t+n+a+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,a,o,s,f,c){var u=0,d=t;return u+=(d=d+n>>>0)<t?1:0,u+=(d=d+a>>>0)<a?1:0,u+=(d=d+s>>>0)<s?1:0,e+r+i+o+f+(u+=(d=d+c>>>0)<c?1:0)>>>0},t.sum64_5_lo=function(e,t,r,n,i,a,o,s,f,c){return t+n+a+s+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function a(e,t,r){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;try{o=r(56).Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),a=t;a<i;a++){var o=e.charCodeAt(a)-48;n<<=4,n|=o>=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function f(e,t,r,n){for(var i=0,a=Math.min(e.length,r),o=t;o<a;o++){var s=e.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}a.isBN=function(e){return e instanceof a||null!==e&&"object"==typeof e&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,t){return e.cmp(t)>0?e:t},a.min=function(e,t){return e.cmp(t)<0?e:t},a.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if("be"===r)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,a=0;for(r=e.length-6,n=0;r>=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<<a&67108863,this.words[n+1]|=i>>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<<a&67108863,this.words[n+1]|=i>>>26-a&4194303),this.strip()},a.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var a=e.length-r,o=a%n,s=Math.min(a,a-o)+r,c=0,u=r;u<s;u+=n)c=f(e,u,u+n,t),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==o){var d=1;for(c=f(e,u,e.length,t),u=0;u<o;u++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},a.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},a.prototype.clone=function(){var e=new a(null);return this.copy(e),e},a.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var c=["","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"],u=[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],d=[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(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],a=0|t.words[0],o=i*a,s=67108863&o,f=o/67108864|0;r.words[0]=s;for(var c=1;c<n;c++){for(var u=f>>>26,d=67108863&f,l=Math.min(c,t.length-1),h=Math.max(0,c-e.length+1);h<=l;h++){var p=c-h|0;u+=(o=(i=0|e.words[p])*(a=0|t.words[h])+d)/67108864|0,d=67108863&o}r.words[c]=0|d,f=0|u}return 0!==f?r.words[c]=0|f:r.length--,r.strip()}a.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,a=0,o=0;o<this.length;o++){var s=this.words[o],f=(16777215&(s<<i|a)).toString(16);r=0!==(a=s>>>24-i&16777215)||o!==this.length-1?c[6-f.length]+f+r:f+r,(i+=2)>=26&&(i-=26,o--)}for(0!==a&&(r=a.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=u[e],h=d[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(h).toString(e);r=(p=p.idivn(h)).isZero()?b+r:c[l-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(e,t){return n(void 0!==o),this.toArrayLike(o,e,t)},a.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},a.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),a=r||Math.max(1,i);n(i<=a,"byte array longer than desired length"),n(a>0,"Requested array length <= 0"),this.strip();var o,s,f="le"===t,c=new e(a),u=this.clone();if(f){for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[s]=o;for(;s<a;s++)c[s]=0}else{for(s=0;s<a-i;s++)c[s]=0;for(s=0;!u.isZero();s++)o=u.andln(255),u.iushrn(8),c[a-s-1]=o}return c},Math.clz32?a.prototype._countBits=function(e){return 32-Math.clz32(e)}:a.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},a.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},a.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},a.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return 0!==this.negative},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},a.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},a.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},a.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},a.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},a.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},a.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},a.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},a.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},a.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},a.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},a.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},a.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},a.prototype.notn=function(e){return this.clone().inotn(e)},a.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},a.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0,a=0;a<n.length;a++)t=(0|r.words[a])+(0|n.words[a])+i,this.words[a]=67108863&t,i=t>>>26;for(;0!==i&&a<r.length;a++)t=(0|r.words[a])+i,this.words[a]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this},a.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},a.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var a=0,o=0;o<n.length;o++)a=(t=(0|r.words[o])-(0|n.words[o])+a)>>26,this.words[o]=67108863&t;for(;0!==a&&o<r.length;o++)a=(t=(0|r.words[o])+a)>>26,this.words[o]=67108863&t;if(0===a&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,r){var n,i,a,o=e.words,s=t.words,f=r.words,c=0,u=0|o[0],d=8191&u,l=u>>>13,h=0|o[1],p=8191&h,b=h>>>13,v=0|o[2],m=8191&v,g=v>>>13,y=0|o[3],w=8191&y,_=y>>>13,k=0|o[4],x=8191&k,S=k>>>13,A=0|o[5],M=8191&A,E=A>>>13,I=0|o[6],P=8191&I,T=I>>>13,C=0|o[7],O=8191&C,R=C>>>13,j=0|o[8],F=8191&j,B=j>>>13,N=0|o[9],z=8191&N,H=N>>>13,L=0|s[0],q=8191&L,D=L>>>13,U=0|s[1],K=8191&U,V=U>>>13,Y=0|s[2],W=8191&Y,Z=Y>>>13,X=0|s[3],Q=8191&X,G=X>>>13,$=0|s[4],J=8191&$,ee=$>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],ae=8191&ie,oe=ie>>>13,se=0|s[7],fe=8191&se,ce=se>>>13,ue=0|s[8],de=8191&ue,le=ue>>>13,he=0|s[9],pe=8191&he,be=he>>>13;r.negative=e.negative^t.negative,r.length=19;var ve=(c+(n=Math.imul(d,q))|0)+((8191&(i=(i=Math.imul(d,D))+Math.imul(l,q)|0))<<13)|0;c=((a=Math.imul(l,D))+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,D))+Math.imul(b,q)|0,a=Math.imul(b,D);var me=(c+(n=n+Math.imul(d,K)|0)|0)+((8191&(i=(i=i+Math.imul(d,V)|0)+Math.imul(l,K)|0))<<13)|0;c=((a=a+Math.imul(l,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,D))+Math.imul(g,q)|0,a=Math.imul(g,D),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(b,K)|0,a=a+Math.imul(b,V)|0;var ge=(c+(n=n+Math.imul(d,W)|0)|0)+((8191&(i=(i=i+Math.imul(d,Z)|0)+Math.imul(l,W)|0))<<13)|0;c=((a=a+Math.imul(l,Z)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,D))+Math.imul(_,q)|0,a=Math.imul(_,D),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(g,K)|0,a=a+Math.imul(g,V)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,W)|0,a=a+Math.imul(b,Z)|0;var ye=(c+(n=n+Math.imul(d,Q)|0)|0)+((8191&(i=(i=i+Math.imul(d,G)|0)+Math.imul(l,Q)|0))<<13)|0;c=((a=a+Math.imul(l,G)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(x,q),i=(i=Math.imul(x,D))+Math.imul(S,q)|0,a=Math.imul(S,D),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,K)|0,a=a+Math.imul(_,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,Z)|0)+Math.imul(g,W)|0,a=a+Math.imul(g,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(b,Q)|0,a=a+Math.imul(b,G)|0;var we=(c+(n=n+Math.imul(d,J)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(l,J)|0))<<13)|0;c=((a=a+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,q),i=(i=Math.imul(M,D))+Math.imul(E,q)|0,a=Math.imul(E,D),n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(S,K)|0,a=a+Math.imul(S,V)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,W)|0,a=a+Math.imul(_,Z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(g,Q)|0,a=a+Math.imul(g,G)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,J)|0,a=a+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(d,re)|0)|0)+((8191&(i=(i=i+Math.imul(d,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((a=a+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(P,q),i=(i=Math.imul(P,D))+Math.imul(T,q)|0,a=Math.imul(T,D),n=n+Math.imul(M,K)|0,i=(i=i+Math.imul(M,V)|0)+Math.imul(E,K)|0,a=a+Math.imul(E,V)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,G)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(g,J)|0,a=a+Math.imul(g,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,a=a+Math.imul(b,ne)|0;var ke=(c+(n=n+Math.imul(d,ae)|0)|0)+((8191&(i=(i=i+Math.imul(d,oe)|0)+Math.imul(l,ae)|0))<<13)|0;c=((a=a+Math.imul(l,oe)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,D))+Math.imul(R,q)|0,a=Math.imul(R,D),n=n+Math.imul(P,K)|0,i=(i=i+Math.imul(P,V)|0)+Math.imul(T,K)|0,a=a+Math.imul(T,V)|0,n=n+Math.imul(M,W)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(E,W)|0,a=a+Math.imul(E,Z)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(S,Q)|0,a=a+Math.imul(S,G)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,J)|0,a=a+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(g,re)|0,a=a+Math.imul(g,ne)|0,n=n+Math.imul(p,ae)|0,i=(i=i+Math.imul(p,oe)|0)+Math.imul(b,ae)|0,a=a+Math.imul(b,oe)|0;var xe=(c+(n=n+Math.imul(d,fe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ce)|0)+Math.imul(l,fe)|0))<<13)|0;c=((a=a+Math.imul(l,ce)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(F,q),i=(i=Math.imul(F,D))+Math.imul(B,q)|0,a=Math.imul(B,D),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(R,K)|0,a=a+Math.imul(R,V)|0,n=n+Math.imul(P,W)|0,i=(i=i+Math.imul(P,Z)|0)+Math.imul(T,W)|0,a=a+Math.imul(T,Z)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,G)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,a=a+Math.imul(_,ne)|0,n=n+Math.imul(m,ae)|0,i=(i=i+Math.imul(m,oe)|0)+Math.imul(g,ae)|0,a=a+Math.imul(g,oe)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(b,fe)|0,a=a+Math.imul(b,ce)|0;var Se=(c+(n=n+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,le)|0)+Math.imul(l,de)|0))<<13)|0;c=((a=a+Math.imul(l,le)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(z,q),i=(i=Math.imul(z,D))+Math.imul(H,q)|0,a=Math.imul(H,D),n=n+Math.imul(F,K)|0,i=(i=i+Math.imul(F,V)|0)+Math.imul(B,K)|0,a=a+Math.imul(B,V)|0,n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(R,W)|0,a=a+Math.imul(R,Z)|0,n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,G)|0)+Math.imul(T,Q)|0,a=a+Math.imul(T,G)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(E,J)|0,a=a+Math.imul(E,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(S,re)|0,a=a+Math.imul(S,ne)|0,n=n+Math.imul(w,ae)|0,i=(i=i+Math.imul(w,oe)|0)+Math.imul(_,ae)|0,a=a+Math.imul(_,oe)|0,n=n+Math.imul(m,fe)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(g,fe)|0,a=a+Math.imul(g,ce)|0,n=n+Math.imul(p,de)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,de)|0,a=a+Math.imul(b,le)|0;var Ae=(c+(n=n+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,be)|0)+Math.imul(l,pe)|0))<<13)|0;c=((a=a+Math.imul(l,be)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(z,K),i=(i=Math.imul(z,V))+Math.imul(H,K)|0,a=Math.imul(H,V),n=n+Math.imul(F,W)|0,i=(i=i+Math.imul(F,Z)|0)+Math.imul(B,W)|0,a=a+Math.imul(B,Z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,G)|0,n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(T,J)|0,a=a+Math.imul(T,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(E,re)|0,a=a+Math.imul(E,ne)|0,n=n+Math.imul(x,ae)|0,i=(i=i+Math.imul(x,oe)|0)+Math.imul(S,ae)|0,a=a+Math.imul(S,oe)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,fe)|0,a=a+Math.imul(_,ce)|0,n=n+Math.imul(m,de)|0,i=(i=i+Math.imul(m,le)|0)+Math.imul(g,de)|0,a=a+Math.imul(g,le)|0;var Me=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;c=((a=a+Math.imul(b,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(z,W),i=(i=Math.imul(z,Z))+Math.imul(H,W)|0,a=Math.imul(H,Z),n=n+Math.imul(F,Q)|0,i=(i=i+Math.imul(F,G)|0)+Math.imul(B,Q)|0,a=a+Math.imul(B,G)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(R,J)|0,a=a+Math.imul(R,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(T,re)|0,a=a+Math.imul(T,ne)|0,n=n+Math.imul(M,ae)|0,i=(i=i+Math.imul(M,oe)|0)+Math.imul(E,ae)|0,a=a+Math.imul(E,oe)|0,n=n+Math.imul(x,fe)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(S,fe)|0,a=a+Math.imul(S,ce)|0,n=n+Math.imul(w,de)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,de)|0,a=a+Math.imul(_,le)|0;var Ee=(c+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(g,pe)|0))<<13)|0;c=((a=a+Math.imul(g,be)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(z,Q),i=(i=Math.imul(z,G))+Math.imul(H,Q)|0,a=Math.imul(H,G),n=n+Math.imul(F,J)|0,i=(i=i+Math.imul(F,ee)|0)+Math.imul(B,J)|0,a=a+Math.imul(B,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(R,re)|0,a=a+Math.imul(R,ne)|0,n=n+Math.imul(P,ae)|0,i=(i=i+Math.imul(P,oe)|0)+Math.imul(T,ae)|0,a=a+Math.imul(T,oe)|0,n=n+Math.imul(M,fe)|0,i=(i=i+Math.imul(M,ce)|0)+Math.imul(E,fe)|0,a=a+Math.imul(E,ce)|0,n=n+Math.imul(x,de)|0,i=(i=i+Math.imul(x,le)|0)+Math.imul(S,de)|0,a=a+Math.imul(S,le)|0;var Ie=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;c=((a=a+Math.imul(_,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(z,J),i=(i=Math.imul(z,ee))+Math.imul(H,J)|0,a=Math.imul(H,ee),n=n+Math.imul(F,re)|0,i=(i=i+Math.imul(F,ne)|0)+Math.imul(B,re)|0,a=a+Math.imul(B,ne)|0,n=n+Math.imul(O,ae)|0,i=(i=i+Math.imul(O,oe)|0)+Math.imul(R,ae)|0,a=a+Math.imul(R,oe)|0,n=n+Math.imul(P,fe)|0,i=(i=i+Math.imul(P,ce)|0)+Math.imul(T,fe)|0,a=a+Math.imul(T,ce)|0,n=n+Math.imul(M,de)|0,i=(i=i+Math.imul(M,le)|0)+Math.imul(E,de)|0,a=a+Math.imul(E,le)|0;var Pe=(c+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,be)|0)+Math.imul(S,pe)|0))<<13)|0;c=((a=a+Math.imul(S,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(z,re),i=(i=Math.imul(z,ne))+Math.imul(H,re)|0,a=Math.imul(H,ne),n=n+Math.imul(F,ae)|0,i=(i=i+Math.imul(F,oe)|0)+Math.imul(B,ae)|0,a=a+Math.imul(B,oe)|0,n=n+Math.imul(O,fe)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(R,fe)|0,a=a+Math.imul(R,ce)|0,n=n+Math.imul(P,de)|0,i=(i=i+Math.imul(P,le)|0)+Math.imul(T,de)|0,a=a+Math.imul(T,le)|0;var Te=(c+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,be)|0)+Math.imul(E,pe)|0))<<13)|0;c=((a=a+Math.imul(E,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(z,ae),i=(i=Math.imul(z,oe))+Math.imul(H,ae)|0,a=Math.imul(H,oe),n=n+Math.imul(F,fe)|0,i=(i=i+Math.imul(F,ce)|0)+Math.imul(B,fe)|0,a=a+Math.imul(B,ce)|0,n=n+Math.imul(O,de)|0,i=(i=i+Math.imul(O,le)|0)+Math.imul(R,de)|0,a=a+Math.imul(R,le)|0;var Ce=(c+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,be)|0)+Math.imul(T,pe)|0))<<13)|0;c=((a=a+Math.imul(T,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(z,fe),i=(i=Math.imul(z,ce))+Math.imul(H,fe)|0,a=Math.imul(H,ce),n=n+Math.imul(F,de)|0,i=(i=i+Math.imul(F,le)|0)+Math.imul(B,de)|0,a=a+Math.imul(B,le)|0;var Oe=(c+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,be)|0)+Math.imul(R,pe)|0))<<13)|0;c=((a=a+Math.imul(R,be)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(z,de),i=(i=Math.imul(z,le))+Math.imul(H,de)|0,a=Math.imul(H,le);var Re=(c+(n=n+Math.imul(F,pe)|0)|0)+((8191&(i=(i=i+Math.imul(F,be)|0)+Math.imul(B,pe)|0))<<13)|0;c=((a=a+Math.imul(B,be)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var je=(c+(n=Math.imul(z,pe))|0)+((8191&(i=(i=Math.imul(z,be))+Math.imul(H,pe)|0))<<13)|0;return c=((a=Math.imul(H,be))+(i>>>13)|0)+(je>>>26)|0,je&=67108863,f[0]=ve,f[1]=me,f[2]=ge,f[3]=ye,f[4]=we,f[5]=_e,f[6]=ke,f[7]=xe,f[8]=Se,f[9]=Ae,f[10]=Me,f[11]=Ee,f[12]=Ie,f[13]=Pe,f[14]=Te,f[15]=Ce,f[16]=Oe,f[17]=Re,f[18]=je,0!==c&&(f[19]=c,r.length++),r};function p(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=l),a.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,a=0;a<r.length-1;a++){var o=i;i=0;for(var s=67108863&n,f=Math.min(a,t.length-1),c=Math.max(0,a-e.length+1);c<=f;c++){var u=a-c,d=(0|e.words[u])*(0|t.words[c]),l=67108863&d;s=67108863&(l=l+s|0),i+=(o=(o=o+(d/67108864|0)|0)+(l>>>26)|0)>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=a.prototype._countBits(e)-1,n=0;n<e;n++)t[n]=this.revBin(n,r,e);return t},b.prototype.revBin=function(e,t,r){if(0===e||e===r-1)return e;for(var n=0,i=0;i<t;i++)n|=(1&e)<<t-i-1,e>>=1;return n},b.prototype.permute=function(e,t,r,n,i,a){for(var o=0;o<a;o++)n[o]=t[e[o]],i[o]=r[e[o]]},b.prototype.transform=function(e,t,r,n,i,a){this.permute(a,e,t,r,n,i);for(var o=1;o<i;o<<=1)for(var s=o<<1,f=Math.cos(2*Math.PI/s),c=Math.sin(2*Math.PI/s),u=0;u<i;u+=s)for(var d=f,l=c,h=0;h<o;h++){var p=r[u+h],b=n[u+h],v=r[u+h+o],m=n[u+h+o],g=d*v-l*m;m=d*m+l*v,v=g,r[u+h]=p+v,n[u+h]=b+m,r[u+h+o]=p-v,n[u+h+o]=b-m,h!==s&&(g=f*d-c*l,l=f*l+c*d,d=g)}},b.prototype.guessLen13b=function(e,t){var r=1|Math.max(t,e),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},b.prototype.conjugate=function(e,t,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=e[n];e[n]=e[r-n-1],e[r-n-1]=i,i=t[n],t[n]=-t[r-n-1],t[r-n-1]=-i}},b.prototype.normalize13b=function(e,t){for(var r=0,n=0;n<t/2;n++){var i=8192*Math.round(e[2*n+1]/t)+Math.round(e[2*n]/t)+r;e[n]=67108863&i,r=i<67108864?0:i/67108864|0}return e},b.prototype.convert13b=function(e,t,r,i){for(var a=0,o=0;o<t;o++)a+=0|e[o],r[2*o]=8191&a,a>>>=13,r[2*o+1]=8191&a,a>>>=13;for(o=2*t;o<i;++o)r[o]=0;n(0===a),n(0==(-8192&a))},b.prototype.stub=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=0;return t},b.prototype.mulp=function(e,t,r){var n=2*this.guessLen13b(e.length,t.length),i=this.makeRBT(n),a=this.stub(n),o=new Array(n),s=new Array(n),f=new Array(n),c=new Array(n),u=new Array(n),d=new Array(n),l=r.words;l.length=n,this.convert13b(e.words,e.length,o,n),this.convert13b(t.words,t.length,c,n),this.transform(o,a,s,f,n,i),this.transform(c,a,u,d,n,i);for(var h=0;h<n;h++){var p=s[h]*u[h]-f[h]*d[h];f[h]=s[h]*d[h]+f[h]*u[h],s[h]=p}return this.conjugate(s,f,n),this.transform(s,f,l,a,n,i),this.conjugate(l,a,n),this.normalize13b(l,n),r.negative=e.negative^t.negative,r.length=e.length+t.length,r.strip()},a.prototype.mul=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},a.prototype.mulf=function(e){var t=new a(null);return t.words=new Array(this.length+e.length),p(this,e,t)},a.prototype.imul=function(e){return this.clone().mulTo(e,this)},a.prototype.imuln=function(e){n("number"==typeof e),n(e<67108864);for(var t=0,r=0;r<this.length;r++){var i=(0|this.words[r])*e,a=(67108863&i)+(67108863&t);t>>=26,t+=i/67108864|0,t+=a>>>26,this.words[r]=67108863&a}return 0!==t&&(this.words[r]=t,this.length++),this},a.prototype.muln=function(e){return this.clone().imuln(e)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}(e);if(0===t.length)return new a(1);for(var r=this,n=0;n<t.length&&0===t[n];n++,r=r.sqr());if(++n<t.length)for(var i=r.sqr();n<t.length;n++,i=i.sqr())0!==t[n]&&(r=r.mul(i));return r},a.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,i=(e-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t<this.length;t++){var s=this.words[t]&a,f=(0|this.words[t])-s<<r;this.words[t]=f|o,o=s>>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t<i;t++)this.words[t]=0;this.length+=i}return this.strip()},a.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},a.prototype.iushrn=function(e,t,r){var i;n("number"==typeof e&&e>=0),i=t?(t-t%26)/26:0;var a=e%26,o=Math.min((e-a)/26,this.length),s=67108863^67108863>>>a<<a,f=r;if(i-=o,i=Math.max(0,i),f){for(var c=0;c<o;c++)f.words[c]=this.words[c];f.length=o}if(0===o);else if(this.length>o)for(this.length-=o,c=0;c<this.length;c++)this.words[c]=this.words[c+o];else this.words[0]=0,this.length=1;var u=0;for(c=this.length-1;c>=0&&(0!==u||c>=i);c--){var d=0|this.words[c];this.words[c]=u<<26-a|d>>>a,u=d&s}return f&&0!==u&&(f.words[f.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},a.prototype.shln=function(e){return this.clone().ishln(e)},a.prototype.ushln=function(e){return this.clone().iushln(e)},a.prototype.shrn=function(e){return this.clone().ishrn(e)},a.prototype.ushrn=function(e){return this.clone().iushrn(e)},a.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<<t;return!(this.length<=r)&&!!(this.words[r]&i)},a.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<<t;this.words[this.length-1]&=i}return this.strip()},a.prototype.maskn=function(e){return this.clone().imaskn(e)},a.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},a.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},a.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},a.prototype.addn=function(e){return this.clone().iaddn(e)},a.prototype.subn=function(e){return this.clone().isubn(e)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(e,t,r){var i,a,o=e.length+r;this._expand(o);var s=0;for(i=0;i<e.length;i++){a=(0|this.words[i+r])+s;var f=(0|e.words[i])*t;s=((a-=67108863&f)>>26)-(f/67108864|0),this.words[i+r]=67108863&a}for(;i<this.length-r;i++)s=(a=(0|this.words[i+r])+s)>>26,this.words[i+r]=67108863&a;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i<this.length;i++)s=(a=-(0|this.words[i])+s)>>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var s,f=n.length-i.length;if("mod"!==t){(s=new a(null)).length=f+1,s.words=new Array(s.length);for(var c=0;c<s.length;c++)s.words[c]=0}var u=n.clone()._ishlnsubmul(i,1,f);0===u.negative&&(n=u,s&&(s.words[f]=1));for(var d=f-1;d>=0;d--){var l=67108864*(0|n.words[i.length+d])+(0|n.words[i.length+d-1]);for(l=Math.min(l/o|0,67108863),n._ishlnsubmul(i,l,d);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,d),n.isZero()||(n.negative^=1);s&&(s.words[d]=l)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},a.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:i,mod:o}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:s.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new a(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new a(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new a(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,o,s},a.prototype.div=function(e){return this.divmod(e,"div",!1).div},a.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},a.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},a.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},a.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},a.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t